+ 1
Could someone explain me how this code works line to line? Thanks.
var a=[9,5,2]; for (var i=1;i<3;i++){ a[0]%=a[i]; } document.write(a[0]);
2 Answers
+ 11
Just hand trace it.
a[0] %= a[1]
// 9 % 5 is 4
// a[0] now stores 4
a[0] %= a[2]
// 4 % 2 is 0
// a[0] now stores 0
document.write(a[0])
// writes 0
+ 1
thanks