Var count = 0 vs. var count === 0; Why doesn't the latter work?


#1

https://www.codecademy.com/courses/javascript-beginner-en-ASGIv/1/1?curriculum_id=506324b3a7dffd00020bf661


SyntaxError: Unexpected token ===


var count === 0;
var loop = function()
{
	while(count<3)
	{
		//Your code goes here!
		console.log("I'm looping!");
		count ++;
		
	}
};

loop();

Why does var count = 0 work but var count === 0 doesn't work?


#2

because a single equal signs assigns a value of 0 to to count (it creates the variable, or update the variable, depending on how you use it), two or three equal signs is used for comparing 0 with count

This should have been covered a long time ago, revisit some exercises if you don't remember.


#3

Yeah, was covered way back in one of the first exercises. Thanks!