Answers for "how to sum all values in an array javascript"

24

sum of all numbers in an array javascript

const arrSum = arr => arr.reduce((a,b) => a + b, 0)
Posted by: Guest on March-23-2020
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
0

sum all values of an array

function array(arr){
   var sum = 0;
   for (var i = 0; i< arr.length; i++){
    sum += arr[i];
   }
   console.log(sum);
 }
 array([5, 1, 3, 3])
Posted by: Guest on July-19-2021

Code answers related to "how to sum all values in an array javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language