25.
What will be the output of the following code snippet?
const name = 'John';
const age = 30;
console.log(`My name is ${name} and I am ${age} years old.`);
ReferenceError: name is not defined.
My name is undefined and I am undefined years old.
My name is ${name} and I am ${age} years old.
My name is John and I am 30 years old.
Correct: D
This code snippet demonstrates the use of template literals in ES6 to dynamically insert variables in a string. The output of this code will be My name is John and I am 30 years old. The variables name and age are interpolated inside the template literal using the ${} syntax.