Back to questions
JuniorTheoryCommon
What does the program print?
const n = 2;
console.log(`a${n}b`, "a${n}b");a2b a${n}b
- Expecting
a2b a2b:${}inserts a value only inside backticks; in ordinary double quotes it is plain text and prints as written. - Expecting
SyntaxErrorfor${inside double quotes: any characters may sit inside quotes, so the string is valid and keeps them as they are.
- How would you build the same
a2bstring with+instead of a template literal? - What does a template literal print when it spans two lines of code?