LESSON 7
Strings
Learning objective: Work with text using strings and template literals.
Understand
Strings hold text data.
Strings are written in quotes. You can join them with +, but template literals using backticks and ${} are cleaner for inserting variables. Strings have handy properties like .length and methods like .toUpperCase().
Analogy: A template literal is like a fill-in-the-blank sentence where variables slot in.
See It in Action
Template literals:
let name = "Sam";
console.log(`Hello, ${name}!`);How it works: The backticks let you embed
${name} directly in the text, producing 'Hello, Sam!'.Try It Yourself
- Store your name in a variable.
- Build a greeting with a template literal.
- Log the string's
.length.
Quick Quiz
What do backtick template literals let you do easily?
Challenge
Build a personalized message using a template literal.
Success condition: Your message correctly inserts a variable into text.
+10 XP
Lesson Complete
You answered correctly and completed the required practice. Your progress has been saved on this device.
Continue to next lesson →