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