Friday, May 4, 2018

How to make the situation true JAVASCRIPT




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

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...