I have this function:
function getTotal () {
var args = Array.prototype.slice.call(arguments);
var total = 0;
for (var i = 0; i < args.length; i++) {
total += args[i];
}
return total;
}
Lets say that I have an array that is filled with numbers and I do not know the length of it:
var numArray = [ ..., ... ];
How can I call the function getTotal
by passing in every element in the numArray
as a parameter?