I have dynamic input of items 0 to N in a function (JavaScript).
In each position have value like items[1,3,4]
, creating a loop:
update: items or "the array" is dynamic I don't have permanent values.
ex.: for (var i = 0;i < items.length; i++){}
Need return the multiplication of all items, only know the total of array (items.length
) inside of "for
".
So.. 1st. need be cumulative
2nd maybe multiply each inside a loop item[value] * item[value] *
3rd maybe if(i == items.length){return total}
(ex.: 1*3*4 = 12)
dont know how to cumulative var total = item[value] * item[value] * ...
function **multiplyEach**(item){
item[1,3,4]; //only ex.:this array have many possibilities of length
for( var i = 0; i <= item.length; i++){
var **items** = item[i] * item[i];
if (i == item.length){
return items;
}
}
}
items have NaN or undefined value in debug of Chrome browser. :/ ..