Summing numbers in a range

Hi Everyone. I am trying to find the sum of numbers in a range. My code works for all examples like 3, 6 --> 18 and 5, 10 ---> 45 , however when I try to do 1,1, it should return 1 but it isnt. Anyone mind lending a hand? See code below


function sumRange(from, to) {
  var result = from;
  if(to > from) {
    while (to > from) {
      from ++;
      result += from;
    }
    return result;
  } else if (from > to) {
    result = to;
    while (from > to ) {
      to++;
      result += to;
    }
    return result;
  }

}

Thanks in advance!

When from and to are equal to each other, both of your if conditions are false.

ahhhhh >=!! Thank you so much

thanks so much!!! appreciate the help