Answers for "function that takes an array of numbers and returns the sum of the numbers"

1

sum of array of number

const sum = [1, 2, 3].reduce((partialSum, a) => partialSum + a, 0);
console.log(sum); // 6
 Run code snippet
Posted by: Guest on February-07-2022
0

return the sum of an array

[0, 1, 2, 3, 4].reduce(function(accumulateur, valeurCourante, index, array){
  return accumulateur + valeurCourante;
}, 10);
Posted by: Guest on March-19-2022

Code answers related to "function that takes an array of numbers and returns the sum of the numbers"

Code answers related to "Javascript"

Browse Popular Code Answers by Language