Three equal comparison


#1

I have looked up the difference between using == and === for comparison in JavaScript and it makes sense.
Some of my students have been asking about why App Lap is forcing them to use three equal signs when comparing any integers against 0. Both operands are integers so no type conversion is necessary.

for example :

var count = 0;
// some code here
if (count == 0)
{
console.log(“zero”);
}

App Lab warns Use ‘===’ to compare with ‘0’;

Does anybody know why only a comparison with 0 generates this error?


#2

Here is a discussion thread about this topic. Hopefully, this will answer your question. http://forum.code.org/t/unit-5-stage-8/6533/3?u=bhatnagars