Console.log question

My code prints when I write it with these kind of quotes (don’t know their name) found next to the #1 button on my keyboard:

console.log(The temperature is ${newton} degrees newton.)

However, it won’t print when I use these quotation marks

console.log('The temperature is {newton} degrees newton.') console.log("The temperature is {newton} degrees newton.")

When should I use quotation marks? When do I use these other marks (found next to the #1 button)? What are these other marks called?

Thanks

Its kinda the same thing. The new mark(found next to the #1 button) is the new es6 equivalent to quotation marks. They did this so old javascript is still compatible with es6 (or so @mtf says over here). These new marks are used so you can use variable names directly in strings without having to close the quotations and add +'s everywhere.

Here is a link on the documentation of this stuff.

2 Likes

Thank you. This is very helpful.