es6 · ES6 Basics
String interpolation is a much-needed new feature that is finally available in JavaScript. See the example below. Is there anything wrong with it?
let name = 'Harry';
let occupation = 'wizard';
console.log(`Hi! My name is ${name}. I'm a ${occupation}.`);Answers
- Nothing wrong with the example. This is how the feature works in ES6.
- The example is wrong. You can't break a String into lines in JavaScript.
- The example is wrong. You can't embed variables in String in JavaScript.
- None of the above.