Just loop from array and get the output
function sumArray(arr){
let total = 0;
arr.forEach((i) => total+=i);
return total;
}
console.log(sumArray([3,45,66]));
Or you can try with reduce as explained by Cristian
function sumArray(arr){
const reducer = (previousValue, currentValue) => previousValue + currentValue;
let total = arr.reduce(reducer)
return total;
}
console.log(sumArray([3,45,66]));
CLICK HERE to find out more related problems solutions.