Sum All Numbers in a Range - help

Sum All Numbers in a Range - help
0

#1

Tell us what’s happening:
Hey,

I haven’t been coding for a while, it feels like it is hard to get back on track.
Can someone tell what is wrong with my code?
I would really appreciate it!

Your code so far


function sumAll(arr) {
  var sum = 0;
arr.sort((a, b) => a - b);
var a = arr[0];
var b = arr[1];
while (a <= b) {
  sum =+ a;
  a++;
}
return sum;
}

sumAll([1, 4]);

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-numbers-in-a-range


#2

That is not a valid operator.


#3

Oh, thanks! What a stupid mistake. It works now!