How to interpolate strings in Javascript?
const character = 'Ryu'
const skill = 'Hadouken'
// output: Ryu attacks with Hadouken!
console.log(`${character} attacks with ${skill}!`)
const a = 1;
const b = 2;
// output: 3
console.log(`${a + b}`)
September 2nd, 2019
Template literals formerly known as template strings are a nice way to write single and multi-line strings with expressions. We have to use backticks instead of single or double quotes for the string. The expressions are wrapped by ${expression}
.