+ 1

I don't understand this exercise of javascript, help!

can someone explain to me why the output is equal to 6? var x=[1,2,4,1]; var sum=0; for (var i=0;i<x.length-1;i++) { sum+=x[i]; } document.write(sum);

21st Oct 2017, 7:35 PM
Angela_g710
Angela_g710 - avatar
5 Respuestas
+ 1
Yes, it's seven, I was wrong to write the question! thanks for your answers, did not know that the value of "sum" also changed! thanks!
21st Oct 2017, 9:49 PM
Angela_g710
Angela_g710 - avatar