Intermediate Algorithm Scripting: Sum All Numbers in a Range

Intermediate Algorithm Scripting: Sum All Numbers in a Range
0

#1

My Solution

function sumAll(arr) {
  let sum = 0;
  let sortedArray = [];
  
  sortedArray = arr.sort(function(a,b) {
    return a > b;
  });
  
  for(i=sortedArray[0];i<=sortedArray[1];i++)
    {
      console.log(sum);
      sum += i;
    }
  
  console.log(sum);
  return sum;
}

sumAll([-9, -15]);

Won’t register as correct, even though it produces same results as the answers in “Hints”. Can anyone tell me why?


#2

Your solution passes for me. What browser are you using ? Are you on beta or the live site ? which tests does it fail for exactly ?


#3

Reloaded the page, and it worked. Originally, none of the tests were actually even showing up. Must have been a bug on loading the tests. :smiley:

(Beta Site)

Ty for response <3.


#5