+ 1

js: y++>=1

var x=1, y=1, z=0; do { z=x+y; } while(++x<=1&&y++>=1); console.log(x,y,z); //2,1,2 This was a SL challenge (not my code). I’d like to understand why y remains 1 in the while-row?

15th Apr 2020, 12:27 PM
Prof. Dr. Zoltán Vass
1 Respuesta
+ 3
In logical && operation, if first case is false then it dont execute next second condition because 0&&0 =0 or 0&&1=0 only.. So y++ won't executes, ++x<=1 false
15th Apr 2020, 12:33 PM
Jayakrishna 🇮🇳