vendredi 24 juin 2016

IF statement bug?

How come this IF statement doesn't work properly?

code:

function testFunction() 
{
    var cnt = 0;    
    alert((!cnt > 1 ? '<= 1' : '> 1'));
}

testFunction();

Not matter what value cnt is set to, it keeps going for the else statement. Could someone explain me why and how?

Fiddle in action:

http://ift.tt/28YAAiK

Edit: I even parseInt variable cnt, still not clue on why this is happening.

Aucun commentaire:

Enregistrer un commentaire