I don't know what is the missing code here it's giving me a headache because of the conditional statement.
Add the missing codes so that the condition below will evaluate to TRUE and print “it works!” in the console.
if (num == 100 && num== 200 && num==300) {
document.write('it works!');
} else {
document.write('it doesnt');
}
Answer
You need to use logical OR ||
, because with logical AND &&
the condition is never true
, if you take the same value of num
.
if (num == 100 || num== 200 || num == 300) {
But in Javascript everything is possible, like: Can (a== 1 && a ==2 && a==3) ever evaluate to true?
No comments:
Post a Comment