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
1const years = [1, 2, 3, 4]
2let total = 0;
3for (let i = 0; i < years.length; i++) {
4
5 total += years[i]
6
7}
8
9console.log(total)
10
11//answer willl be 10
1//these are the values//
2var values = [
3 '1',
4 '2'
5]
6//makes a variable named total, adding together the values
7var total = values[0] + values[1]
8
9//prints out the variable named total
10console.log(total);