Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Template Literals worksheet is part of the JavaScript Coding without HTML and CSS journey. Print it as a booklet?
Shade in the A or B circle for each question.
Hi ${name} valid template literal syntax?Hi $name (without braces) interpolate the variable name?Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1`Hi ${name}!` | AWrong - missing curly braces around name | |
| 2`Total: ${price + tax}` | BWrong - single quotes don't support ${} interpolation | |
| 3Wraps a string in backticks instead of quotes | C`Hello!` | |
| 4Embeds a variable's value directly inside a string | DA template literal that calculates and inserts an expression | |
| 5'Hi ${name}' | E${score} | |
| 6`Hi $name` | FA template literal that inserts the value of name |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
${} — Syntax used inside backticks to embed a variable or expression directly into a string.let msg = `Hello, ${name}!`;let msg = `Hello, ${name}!`;let msg = `Hello, ${name}!`;let msg = `Hello, ${name}!`;let greeting = `Total: ${price + tax}`;