Intro to JavaScript for back-end API's - var question

Hi there,

I have a very basic question: do I need to put the var’s string inside parenthesis? I’ve noticed that when I run the code, both of these two forms print correctly:

1.)
var favoriteFood = (‘pizza’);
var numOfSlices = (8);
console.log(favoriteFood);
console.log(numOfSlices);

2.)

var favoriteFood = ‘pizza’;
var numOfSlices = 8;
console.log(favoriteFood);
console.log(numOfSlices);

https://www.codecademy.com/paths/create-a-back-end-app-with-javascript/tracks/bapi-javascript-fundamentals/modules/intro-to-javascript-for-apis/lessons/variables/exercises/var

Not necessary. An assignment is not an argument, but an object reference.

Yes. However, consider using const or let, and let var slip into the oblivion that is the past.

1 Like

Thanks! I’m planning on doing so, however it’s recommended to just learn what var was and the next part is to learn how to use const and let - thanks for the info and quick response!

1 Like