1const arr = [1, 2, 3, 4];
2const sum = arr.reduce((a, b) => a + b, 0);
3// sum = 10
1function getArraySum(a){
2 var total=0;
3 for(var i in a) {
4 total += a[i];
5 }
6 return total;
7}
8
9var payChecks = [123,155,134, 205, 105];
10var weeklyPay= getArraySum(payChecks); //sums up to 722
1// If you do not want to use array.reduece you can itereate through the array and then get the solution.
2const getSum = (arr)=>{
3 let sum = 0;
4 for(key of arr){
5 sum += key
6 }
7 return sum
8}
9