Why I can't do this: ${someValue} in JavaScript / Typescript? [duplicate]
You write single quotes, which doesn't have interpolation capability.
Please try "backtick" char, which will solve your issue
`Hello ${a}`
You can read more about this here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
Only works with backticks, not quotes.
Do `Hello ${a}` instead of 'Hello ${a}'
whenever you want to use template string, you have to wrap up with the backtick (type alt
+ 96
), the correct syntax is:
`string ${YOUR_VARIABLE} string`
read this document: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals