1console.log(
2 [1, 2, 3, 4].reduce((a, b) => a + b, 0)
3)
4console.log(
5 [].reduce((a, b) => a + b, 0)
6)
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