Tell us what’s happening:
What is wrong with my code and why i get undefined in console?
Your code so far
function sumAll(arr) {
let arno = arr.sort((a,b) => a - b);
let arn = [];
for(let i = arno[0]; i < arno[1]; i++){
arn.push(i);
};
return arn.reduce((sum,num) => sum + num);
}
sumAll([1, 4]);
Your browser information:
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0
.
Challenge: Sum All Numbers in a Range
Link to the challenge: