Why ${VARIABLE} does not work?

Hi all,
I have typed:
“const ticker = prompt(“Enter ticker of cryto to buy it:”);
const amount = +prompt(‘How much of ${ticker} would you buy?’);
console.log(‘You have just bought ${amount} of ${ticker}’); "
I have put the data into the prompt
and The result was:
" You have just bought ${amount} of ${ticker}”
why the console hasn’t output a sentence with a given value of variable amount and ticker?

Thanks
Kacper Pajak

Hey @Kacper

In order to use this ES6 string substitution you need to use backticks (it’s the key right above the Tab key). So it should be:

// Simple string substitution
var name = "Kacper";
console.log(`Yo, ${name}!`);

// => "Yo, Kacper!"

Cheers!

2 Likes

Thank you JJ
it works

1 Like