Why I can't do this: ${someValue} in JavaScript / Typescript?

I have an issue. JavaScript do not recognize code inside curly braces:

let a = 'John'; let s = 'Hello ${a}'; // output: 'Hello ${a}' instead of 'Hello John'

I have updated Typescript to latest version: npm install typescript@latest

>Solution :

Only works with backticks, not quotes.

Do `Hello ${a}` instead of ‘Hello ${a}’

Leave a Reply