I'm sure that this is simple, but the solution is eluding me. I want to write a function that will result in: 1000 + 1001 + 1002 + 1003 + 1004 (so I'll output 5010)
I have a form where the user inputs a number x (1000 in this case) and a number of times it will iterate y (5 in this case)
I know that I need to store the value each time through in var total, but I'm not quite getting it.
I have this so far:
function baleTotal(){
var x = document.addBale.strt.value;
var y = document.addBale.baleNum.value;
var calc = Number(x);
total = 0;
for (var y; y > 0; y--) {
calc++;
}
document.addBale.result.value = total;
}
for (var y; y > 0; y--)<--- what's this?