Answers for "how to do the sum of list in javascript"

1

how to get sum array in javascript

let sub1 = (arr) => arr.reduce( (x,y) => x+y);

console.log(sub1([2, 4, 9]));
console.log(sub1([15, 200, 18, 0, 18, 18]));
console.log(sub1([100, 4, 17, 29, 81]));
Posted by: Guest on March-31-2022
1

how to find the sum of array using JavaScript

// If you do not want to use array.reduece you can itereate through the array and then get the solution.
const  getSum = (arr)=>{
  let sum = 0;
  for(key of arr){
    sum += key
  }
  return sum
}
Posted by: Guest on October-03-2021

Code answers related to "how to do the sum of list in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language