0
0
Javascriptprogramming~10 mins

Template literals in Javascript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A${name}
B'name'
Cname.toUpperCase()
Dname
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.
2fill in blank
medium

Complete 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'
A${age}
Bage
C'age'
Dage.toString()
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.
3fill in blank
hard

Fix 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'
A${score}
Bscore
C'score'
Dscore.toFixed(2)
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving out the ${} and just writing the variable name.
Putting the variable name in quotes.
4fill in blank
hard

Fill 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'
A${firstName}
BfirstName
C${lastName}
DlastName
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without ${}, which will print them as text.
Putting variables in quotes.
5fill in blank
hard

Fill 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'
A${city}
B${state}
C${zip}
Dcity
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving out ${} around variables.
Putting variables in quotes.
Missing commas or spaces between variables.