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
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
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