+ 2
Why is answer 11???
for(x=1; x<6; x+=2) { x=x*x} alert (x)
2 Réponses
+ 13
for (x = 1; x < 6; x += 2)
x = x * x
alert(x)
x is 1. x < 6 is true, first loop executes. x = 1 * 1, x is 1. x += 2, x is 3.
x is 3. x < 6 is true, second loop executes. x = 3 * 3, x is 9. x += 2, x is 11.
x is 11. x < 6 is false, loop ends.
alert(x). Outputs 11.
+ 1
holly js! thanks))))))