JavaScript Strings
JavaScript strings are used for storing and manipulating text.
String Length
The length of a string can be found with the built-in length property:
javascript
let txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
let length = txt.length; // length will be 26Escape Characters
Because strings must be written within quotes, JavaScript will misunderstand this string:
javascript
let text = "We are the so-called "Vikings" from the north.";The solution to avoid this problem, is to use the backslash escape character.
javascript
let text = "We are the so-called \"Vikings\" from the north.";Test Yourself with an Exercise
How do you find the length of a string variable called `txt`?