0
How to get total for array?
How to get total for array?
1 ответ
+ 1
var a=[ ... ];
var count_items_of_a=a.length; // total as meaning number of elements
var sum_items_of_a=sum_items(a); // total as meaning sum of elements
function sum_items(arr) { // custom function to sum all elements of an array
var r=arr[0];
for (var i=1; i<a.length; i++)
r+=r;
return r;
}