Quotes help make search much faster. Example: "Practice Makes Perfect"

Saturday, May 13, 2017

FreeCodeCamp Sum All Numbers In Range Sample Solution


function sumAll(arr) {
  var sorted = arr.sort(function(a, b){return a-b});
  var sum = 0;
  for(var i=sorted[0]; i<=sorted[1]; i++){
    sum += i;
  }
  return sum;
}

sumAll([1, 4]);

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts