String Methods
Useful methods: toUpperCase, toLowerCase, trim, slice, replace, replaceAll, includes, startsWith, endsWith, indexOf, split, repeat and padStart.
split turns a string into an array and join turns an array back into a string.
Example
const text = " Learn to code ";
console.log(text.trim().toUpperCase());
console.log(text.includes("code"));
console.log(text.trim().slice(0, 5));
console.log("a-b-c".split("-"));
console.log("ha".repeat(3));
console.log("7".padStart(3, "0"));Exercise
Remove spaces from both ends.
" hi ".()
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.