Can someone explain to me or point me to documentation as to why the following function doesn't work?
var x = 1;
var y = 2;
var z = 1;
function logicTest() {
if ((x && y && z) === 1 ) {
return true;
} else {
return false;
}
}
I know that I can type it out the long way as follows:
function logicTest() {
if (x === 1 && y === 1 && z === 1 ) {
return true;
} else {
return false;
}
}
But I'm really trying to understand why the first doesn't work and also if there is a better way of typing the second if/then statement or if that is just the way it will always have to be.
Thanks!
Aucun commentaire:
Enregistrer un commentaire