+ 2

How this code output 11 help!!

var x=1; for(;x<6;x+=2){ x=x*x; } alert(x)

28th Jan 2018, 3:26 PM
HRMtech
HRMtech - avatar
1 Odpowiedź
+ 18
after loop1 ) x=1*1 + 2 =3 [3 <6 , condition true] after loop2) x=3*3 + 2 =11 condition false [11 is not < 6] //loop stops
28th Jan 2018, 3:31 PM
Gaurav Agrawal
Gaurav Agrawal - avatar