Sum All Numbers in a Range console undefined

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++){

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:

  1. Do you need to sum numbers including min and max? If yes, then you need to check your for loop :wink:
  2. To see something in console, you need to log(). Try: console.log(sumAll([3, 7]));
1 Like

Thanks a lot! I just did <= instead of < and it worked