Hi,
can anyone help with this?
I have written code which should pass all the tests for the Sum All Numbers in a Range challenge, but FCC doesn’t recognise it.
var sum = 0;
function sumAll(arr) {
arr.sort(function(a,b){
return a - b;
});
for (var i = arr[0]; i<arr[1]+1; i++)
sum += i;
return sum;
}
sumAll([10, 5]);
I’m happy to rewrite my solution using the Math.max function as advised, but the above solution came to me pretty quickly and does the job nicely, so am wondering why the tests fail?
Any feedback appreciated!
Thanks
Colin