If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Intro to JS: Drawing & Animation

### Text and Strings

Here's a review of what we covered in this tutorial on text.

Before this tutorial, we were using number values for most things- passing numbers into functions, storing numbers in variables, etc. As you've now seen, we can also use text values, and we call those strings in JavaScript - think of them as a "string" of letters.

To create a string, we surround text in matching quotation marks:

"Hello World!"

We have to actually do something with that string - like pass it to the text() command:

text("Hello World!", 100, 100);

We could also store it in a variable, and then pass that variable into the text() command:

var myGreeting = "Hello World!";
text(myGreeting, 100, 100);


Note that we can also use single quotation marks:

var myGreeting = 'Hello World!';

But we *can't* mix and match quotation marks - that's an error! Pick either single or double marks, and stick with it.

var myGreeting = 'Hello World!"; // oh noes!

Just like we can manipulate number values, we can also manipulate strings, like if we want to add one string to another string:

var myGreeting = "Alo";
var myName = "Winston";
var sayHello = myGreeting + ", " + myName + "!"; // Alo, Winston!


We can also combine strings with number values, like so:

var xPos = 10;
var yPos = 20;
var label = "The coordinates are " + xPos + ", " + yPos;


We also saw that we can use different commands to change the text size and text font when we display string using the text() command. You can read more about those in the text section of our documentation.