Ad
  • Custom User Avatar

    Don't use global variables ;-)

  • Custom User Avatar

    (You should format your code)

    Firstly there's no proper sumOfNum declaration, and I'm surprised that it's even working for you (is it?).
    Secondly, your loop is working with wrong bounds because given two integers A and B, which can be positive or negative, find the sum of all the numbers between including them too.
    Thirdly, you can't console.log() after return - you're trying to perform an operation after the function has already stopped working.