by @codeexamples

How to interpolate variables in strings JavaScript

Home » javascript » How to interpolate variables in strings JavaScript

To interpolate variables in strings we need to use template literals in JavaScript.

Example

const a = 2;
const b = "is number"

const c = `Two ${a} ${b}`; // without concatenation

console.log(c); // Two 2 is number

Template literals are new way of declaring strings by using the back-tick () instead of double or single quotes.