[Javascript] How to insert a value of a variable into a string in JavaScript?
I want to insert the value of a varable into a string, for example,
console.log("Product of "+ x +" and " + y +" is: ", x * y);
How can I write this line of code without using + to concatenate in Javascript?
1 Answer
4 years ago by Jahaan
Use template literals like below
console.log(`Product of ${x} and ${y} is: ${x * y}`);
4 years ago by Meera