JavaScript Template Literals — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Template Literals lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Insert a value
easy10 minUse a template literal to greet the name.
- 2
Insert an expression
easy10 minShow the price with twenty percent added.
- 3
Use a ternary inside
easy10 minChoose the singular or plural wording.
- 4
Build a multi-line string
easy10 minReport how many lines a two-line template holds.
- 5
Combine two values
medium10 minReport a name and an age in one sentence.
Find the bug(5)
- 1
Fix the quotes used instead of backticks
easy8 minA placeholder only works inside backticks.
- 2
Fix the missing dollar sign
easy8 minA placeholder needs a dollar before the braces.
- 3
Fix the expression left outside
easy8 minThe calculation should happen inside the placeholder.
- 4
Fix the joined string left as is
easy8 minRewrite the plus signs as a template literal.
- 5
Fix the escaped newline in backticks
easy8 minA real line break works directly inside backticks.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace