Template Literal in JavaScript

Level 251 keystrokes

This uses a template literal to embed the variable age in a string.

JavaScript code

// Declare a variable age with value 25
1let age = 25;
// Template literals use backticks ` instead of quotes
// ${...} embeds expressions inside the string
// This is cleaner than "I am " + age + " years old"
2console.log(`I am ${age} years old`);

Output

I am 25 years old
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this JavaScript code and how often they appear.

  • ;× 2
  • `× 2
  • .× 1
  • (× 1
  • )× 1
  • {× 1
  • }× 1
  • =× 1
  • $× 1

More JavaScript examples at level 2

← JavaScript typing practice