Do we need apostraphes for number variables?

Hi there! I am a bit confused about this exercise. In is not consistent with what is explained about the syntax of a variable: we supposed to wrap the value in apostrophe - in this case ‘pizza’ and ‘8’. However, it keeps telling me wrong answer and is showing up this as the right way:

var favoriteFood = ‘pizza’;
var numOfSlices = 8;

Notice 8 instead of ‘8’. Why?

3 Likes

We do not write quotes around a number since that would make it a string. We can only do arithmetic with numbers.

'8' + '4' === '84'

8 + 4 === 12
23 Likes

Great question, even better answer. Concise, bravo !

3 Likes