this is basically the code, I already got the right answer but I'm just trying to figure out how the process work
total = 20
var myArr = [ 2,3,4,5,6];
var total = 0;
for (var d = 0; d < myArr.length; d++){
total += myArr[d];
}
and I did this
var myArr = [ 2,3,4,5,6];
var total = "";
for (var d = 0; d < myArr.length; d++){
total += myArr;
}
the output is.... (total is =""; so I can see what's happening inside but..
total= 2,3,4,5,62,3,4,5,62,3,4,5,6
and got confuse then I change the myArr to d
var myArr = [ 2,3,4,5,6];
var total = 0;
for (var d = 0; d < myArr.length; d++){
total += d;
}
why is it
total = 10?