kalidasm
6/19/2019 - 1:54 PM

Sum of Numbers in an Array

Sum of Numbers in an Array

const numbers = [10, 20, 30, 40];

function sum(arr){
  let result = 0;

  for(let i = 0; i < arr.length; i++){
    result = result + arr[i];
  }
  
  return result;
}

console.log(sum(numbers)); // => 100