+ 1

Why this code give the answer 8 ?,I don't know of this,please explain given below this js code!

var sum=0; var x=3; var y=5; for(x;x<=y;x++){ if(x==4) continue; sum+=x; } alert(sum);

16th Jul 2020, 5:48 PM
ILLUMINATIE
ILLUMINATIE - avatar
3 RĂ©ponses
+ 2
When x=3 sum=sum+x =0+3=3 when x=4 ,control goes back to loop due to continue keyword and now x=5 so sum=sum+x =3+5=8
16th Jul 2020, 5:53 PM
Abhay
Abhay - avatar
+ 1
Thanks 😊
16th Jul 2020, 5:56 PM
ILLUMINATIE
ILLUMINATIE - avatar
0
✌,your welcome
16th Jul 2020, 5:56 PM
Abhay
Abhay - avatar