Strings
A string is text in single or double quotes. Use \n for a new line and \" for a quote inside double quotes. length gives the number of characters and square brackets read a character by position.
Strings are immutable: methods return a new string rather than changing the original.
Example
const word = "JavaScript";
console.log(word.length);
console.log(word[0]);
console.log(word[word.length - 1]);
console.log("She said \"hi\"");
console.log("Java" + "Script");Exercise
Get the number of characters.
"hello".Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.