26th Aug 2017, 2:09 AM
ARB
ARB - avatar
3 Antworten
+ 11
var a = 3; var b = 7; if((a++ > 5) && (b > 4)){ // current value of a=3 is 3>7 no so condition is false document.write(b); }else{ document.write(a); //it goes to else outputs 4 (because a is post incremented after previous condition) }
26th Aug 2017, 2:13 AM
P R
P R - avatar
+ 7
As a=3 and a++ is not greater than 5, so if condition becomes false.. So, the else condition will be executed in else we have to print a Initially a=3 after incrementation a++=>a=a+1=> 4 Now, a becomes 4 i.e a=4 Hence, you'll get 4 as output...
26th Aug 2017, 4:49 AM
Ankit Saxena
Ankit Saxena - avatar
+ 4
var a = 3; var b = 7; if((a++ > 5) && (b > 4)){ document.write(b); }else{ document.write(a); } Output is 4. That's because a++>5 is false, because a is 3, but after testing it becomes 4. Since one of the conditions is false in an And statement, the whole is false. So, a is outputted, which is presently 4. Hope I helped.
26th Aug 2017, 4:57 AM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar