Design a Sum All Numbers Algorithm - Design a Sum All Numbers Algorithm

Tell us what’s happening:

Hello. My code does not pass a single test. Can’t get why. It renders needed results… Thanks in advance!

Your code so far

function sumAll(arrOf2) {
  minNum = Math.min(...arrOf2);
  maxNum = Math.max(...arrOf2);
  let sum = 0;
  for (let i = minNum; i <= maxNum; i++) {
    sum += i;
  };
  return sum;
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36

Challenge Information:

Design a Sum All Numbers Algorithm - Design a Sum All Numbers Algorithm
https://www.freecodecamp.org/learn/full-stack-developer/lab-sum-all-numbers-algorithm/lab-sum-all-numbers-algorithm

Welcome to the forum @yaroha.egor

Try calling the function.

Happy coding

1 Like

Thank you! I wonder why online compilers does not throw a reference error like it showed me here when i tried to call it…

that depends on if the environment you are using is in strict mode or not, modern JavaScript enviroments tend to all be in strict mode, freeCodeCamp is in strict mode, it seems that others you are using are not.

Here more infos

1 Like