JS BASICSChapter 1 · JS Basics
Strings and Template Literals
Wrap text in backticks to make a template literal: anything inside ${...} is worked out and dropped into the string. Strings also come with methods: .toUpperCase(), .trim(), .includes(), .split(), .replace(), and the .length property counts characters. String methods return a new string; the original never changes.
Worked example
How it reads
- Backticks plus
${...}drop values straight into text .trim()removes spaces from both ends.split(" ")breaks text into an array of words
Common mistakes
- Using normal quotes with
${name}prints the braces literally. Only backticks switch them on.

Cloud tip: Template literals can span several lines, which makes them handy for longer messages.


