1console.log(
2 [1, 2, 3, 4].reduce((a, b) => a + b, 0)
3)
4console.log(
5 [].reduce((a, b) => a + b, 0)
6)
1var numbers = [3, 5, 7, 2];
2var sum = numbers.reduce((x, y) => x + y);
3console.log(sum); // returns 17
4
5// other way
6
7x = sumAll(1, 123, 500, 115, 44, 88);
8
9function sumAll() {
10 var i;
11 var sum = 0;
12 for (i = 0; i < arguments.length; i++) {
13 sum += arguments[i];
14 }
15 return sum;
16}
1//Raju Molla Eastern University
2var arr=[1,2,3,4,5];
3var ans=0;
4arr.map(ele=>{
5 ans+=ele
6})
7console.log(ans);