0
Can anyone explain This practice
2 Answers
+ 3
var x= 6;
var y= 0;
while (x>0 && y<6)
{
x--;
y=y+x
}
document.write(y);// result 9
At first y is 0 then x is decreased to 5,
so y=0+5=5
then x is decreased to 4
so y=5+4=9
since y is now 9 and 9 is not <6,
loop stops running.
answer is 9
0
thank brains for your explanation