The else-statement below never executes even if the if-statement is false. I think I've made some very basic mistake but can't figure out what.
var a = ["king","queen","100"];
for (var i=0; i<a.length; i++) {
if (a[i] === "king" || "queen"){
console.log("monarch");
}
else {
console.log("The number is: "+ parseInt(a[i]));
}
}
// This prints out "monarch" 3 times
a[i] === "king" || a[i] === "queen"a[2] === "king" || a[2] === "queen"isfalse.parseInt(a[i]), because you add a string to the string.a[i] === "king" || "queen"you are asking if a[i] equals to "king", and after you ask another question, literaly"queen", but you want to aska[i]==="queen". so your conditional should be like @OriDrori says