I needed help better understanding a problem in the book.
function addUp(numArray){
var total = 0;
for (var i = 0; i < numArray.length; i++){
total += numArray[i];
}//close for loop
return total;
}//close function addUp
var theTotal = addUp([1, 5, 3, 9]);
What is the theTotal = ____
Which I know is 18.
My question is what does += mean? Does it mean first add both the they equal the answer? A example would be Great Thank You.
Also I having trouble understanding the loop I understand the i++ will increase 0 to one up which is 1 and so forth but I dont understand how this would fit into (total += numArray.length[i]
Please explain. Thank You
This post has been edited by wheresdavid: 20 February 2013 - 08:42 PM











