sum of array element
JavaScript
function sum(arr){
var total =0;
arr.forEach(function(element){
total+=element;
});
return console.log(total);
}
sum([1,2,3]);
function sum(arr){
var total =0;
arr.forEach(function(element){
total+=element;
});
return console.log(total);
}
sum([1,2,3]);