Why is `console.log("25 + 3.5")` printing out `25 + 3.5` instead of 28.5?


#1

Question

Why is console.log("25 + 3.5") printing out 25 + 3.5 instead of 28.5?

Answer

When you add “” to something you creating a string, so JavaScript doesn’t read “25 + 3.5” as a mathematical operation but rather a string of characters. Removing the “” makes JavaScript read the operation correctly as intended.