Strings
Prerequisites: Data types
A string is text, written inside single '...', double "...", or
backtick `...` quotes.
const greeting = "Hello";
console.log(greeting.toUpperCase());
console.log(greeting.length);
Expected output
HELLO
5
Strings come with useful built-in methods like .toUpperCase(),
.toLowerCase(), and .trim() (removes surrounding whitespace).
Common mistakes
- Trying to change a character in a string directly (
str[0] = "H") — strings are immutable in JavaScript; build a new string instead.