JavaScript Strings
A string is a piece of text.
Letters, words, sentences, and even empty text can be strings.
Think of beads on a string. Each character is one bead.
Making strings
Joining strings
Template strings
Length and indexes
Quotes
You can use double quotes or single quotes.
Pick one style and stay steady in a file.
Joining with plus
Use + to glue strings together.
This is called concatenation.
Template strings
Backticks let you drop values inside with a dollar sign and curly braces.
This reads like filling blanks in a sentence.
Length
.length counts the characters.
Spaces count too.
Indexes
Each character has a number seat.
The first seat is 0.
Strings are not changed in place
When you build a new string, you get a new value.
The old text stays the same unless you save over the variable.
Tip: If a number looks stuck to text, check for strings. "2" + 2 becomes "22".
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.