Friday, 4 May 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

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...