sum +=i | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

sum +=i

var sum = 0; for (i=4;i<8;i++){ if(i==6){ continue;} sum=+1;} why sum is 16 ?

27th Sep 2017, 9:59 AM
Grigoriy
Grigoriy - avatar
1 Antwort
+ 13
Your code is wrong, its sum += i (i.e. sum = sum+i) only then you can get 16. 0+4 = 4 4+5 = 9 Now, leaving 6 because of the continue statement, i would move on to the next iteration that is 7. 9+7 = 16 And, the loop terminates!
27th Sep 2017, 10:03 AM
Dev
Dev - avatar