Basics
Strings
Text values with rich built-in methods and template literals.
1. Explanation
Strings are sequences of characters. Use single, double or backtick quotes. Backticks enable template literals — multiline strings and ${expression} interpolation. Useful methods: length, toUpperCase, toLowerCase, includes, indexOf, slice, split, replace, trim, repeat.
2. Example
Try it yourself
Console
Click Run to see output.
3. Expected output
output
10
JAVASCRIPT
true
java
["a","b","c"]
I am 22 years old4. Common mistakes
- ✗Trying to mutate a string (s[0] = 'A') — strings are immutable
- ✗Using + for complex concatenation instead of template literals
- ✗Forgetting that .replace replaces only the first match without /g flag
5. Practice questions
- Reverse a string
- Count how many times the letter 'a' appears in a sentence
- Capitalize the first letter of each word