Answers for "freecodecamp intermediate algorithm scripting sum all numbers in a range"

0

freecodecamp intermediate algorithm scripting sum all numbers in a range

function sumAll(arr) {
  var total = 0
  if(arr[0] < arr[1){
  for(var i = arr[0]; i <= arr[1]; i++){
total += i
  }
  }else{
    for(var i = arr[1] ; i <=arr[0] ; i++){
total += i
  }
  }
  return total
}
Posted by: Guest on September-12-2020

Code answers related to "freecodecamp intermediate algorithm scripting sum all numbers in a range"

Browse Popular Code Answers by Language