Questions about chapter 11 Practice exercises - More variables

Hello , in question 14 i dont really understand what the difference between my answer:

console.log("Crypto 1:",crypto1);
console.log("Crypto 2:",crypto2);
console.log("Crypto 3:",crypto3);

and the answer in the solutions :

console.log(`Crypto 1: ${crypto1}`);
console.log(`Crypto 2: ${crypto2}`);
console.log(`Crypto 3: ${crypto3}`);

Is there any difference between them?or its just two ways to do one thing… :thinking:

thx :innocent:

1 Like

It is two ways to do one thing. With console.log() function I personally prefer the first way

console.log("Crypto 1:", crypto1);
2 Likes

thx @itworksonmymachine !

and what the $ means?)

@DimaSha this is so called “string interpolation syntax” in JavaScript. It means that if you want to insert some variable into a string you can use this syntax. It is important that if you want to use exactly interpolation syntax, your string must start and end with backtick ` symbol and dollar sign $ with curly braces {} is where you put your variable:

`Crypto 3: ${crypto3}`

but you can also use old good string concatenation syntax. Functionality is identical to the interpolation one described above.

"Crypto 3: " + crypto3;
'Crypto 3: ' + crypto3;
2 Likes