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}`)
Copy

September 2nd, 2019

# Template Literals

Add to bookmarks

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}.

Tracking with Matomo to improve the UX. See Privacy Policy for more details.