Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a template literal that includes the variable name.
Javascript
const greeting = `Hello, [1]!`; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the variable name in quotes, which makes it a string.
Using ${} inside the blank when it's already inside a template literal.
✗ Incorrect
In template literals, variables are inserted directly inside ${}, but since the backticks and ${} are already used, here we just need the variable name inside the template literal expression.
2fill in blank
mediumComplete the code to include the variable age inside the template literal.
Javascript
const message = `You are [1] years old.`; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the variable name without ${}, which will print it as text.
Putting the variable name in quotes, making it a string.
✗ Incorrect
To insert a variable inside a template literal, you must wrap it with ${} inside the backticks.
3fill in blank
hardFix the error in the template literal to correctly include the variable score.
Javascript
const result = `Your score is [1].`; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving out the ${} and just writing the variable name.
Putting the variable name in quotes.
✗ Incorrect
Variables inside template literals must be wrapped in ${} to be evaluated and included in the string.
4fill in blank
hardFill both blanks to create a template literal that includes firstName and lastName variables.
Javascript
const fullName = `[1] [2]`;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without ${}, which will print them as text.
Putting variables in quotes.
✗ Incorrect
To include variables inside a template literal, wrap each variable with ${}.
5fill in blank
hardFill all three blanks to create a template literal that includes city, state, and zip variables separated by commas.
Javascript
const address = `[1], [2] [3]`;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving out ${} around variables.
Putting variables in quotes.
Missing commas or spaces between variables.
✗ Incorrect
Each variable inside a template literal must be wrapped with ${} to be evaluated and included in the string.