+ 1

Why this ???

Why It = 16 ??? ??? ??? What is the output of this code? var sum=0; for(i=4; i<8; i++) { if (i == 6) { continue; } sum += i; } document.write(sum);

17th Jul 2018, 11:16 AM
DANIOALEKSANDro
DANIOALEKSANDro - avatar
4 odpowiedzi
+ 4
You are adding number from 4 to 7 through for loop and if number is 6 you are skipping it by continue. Hence 4+5+7 =16 Hope this helps ☺️☺️.
17th Jul 2018, 11:21 AM
Meet Mehta
Meet Mehta - avatar
+ 2
4 gets added to sum, then 5 gets added to sum, then 6 is not and then 7 is added to sum. So sum is 16.
17th Jul 2018, 11:22 AM
Satyam
+ 2
seriously! thx ;)
17th Jul 2018, 11:25 AM
DANIOALEKSANDro
DANIOALEKSANDro - avatar
+ 2
when value of i is 6 for loop will continued and 4+5+7=16
17th Jul 2018, 12:26 PM
Vimlesh Kumar
Vimlesh Kumar - avatar