Here's a review of what we covered in this tutorial on text.
To create a string, we surround text in matching quotation marks:
We have to actually do something with that string - like pass it to the
text("Hello World!", 100, 100);
We could also store it in a variable, and then pass that variable into the
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!
When we combine strings in JS, we call that "concatenating strings." 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.