0
Javascript if clause
Suppose: var a = 30; var b = 5; var zero = a%b; if(zero) console.log(10); else console.log(20); Hi class, in my opinion, the output must be 20, because if(zero) is equals to if(0), so the statement(s) inside else clause will be executed. What is your opinion.
2 Réponses
+ 1
Is this a quiz question? You need to understand from this, but not a direct answer. The if statement evaluates the condition inside the parentheses. If the condition is truthy, meaning it's not zero, undefined, null, false, NaN, or an empty string (""), then the code inside the if block will be executed. Now understand this case:
https://sololearn.com/compiler-playground/c90EBEbV2RBJ/?ref=app
+ 1
Yes, that's right.