In JavaScript, strings have built-in methods to change their case:
s.toUpperCase() // converts all characters to uppercase
s.toLowerCase() // converts all characters to lowercase
Here are some examples:
let word = "Hello World";
console.log(word.toUpperCase()); // "HELLO WORLD"
console.log(word.toLowerCase()); // "hello world"
let name = "ALICE";
console.log(name.toLowerCase()); // "alice"
These methods return a new string — the original is not modified.
Assignment
Follow the Coding Tutorial and convert word to both uppercase and lowercase!
Hint
Use word.toUpperCase() and word.toLowerCase().
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
