+ 1

Please can any one help me explain why the answer to this code is "6"?

var i ,s; s=0; for(i=0; i<=3; i++){ s+=i; } document. write(s);

21st Aug 2017, 9:08 AM
Reward
Reward - avatar
1 ответ
+ 3
you're adding i to s every iteration. 1. 0+1 = 1 2. 1 + 2 = 3 3. 3 + 3 = 6
21st Aug 2017, 9:14 AM
Sean Patrick Franklin
Sean Patrick Franklin - avatar