Pass an array of two numbers and return the sum of those two numbers plus the sum of all the numbers between them. The lowest number will not always come first.

For example, sumAll([4,1]) should return 10 because sum of all the numbers between 1 and 4 (both inclusive) is 10.

function sumAll(arr) {
  let max = Math.max(...arr);
  let min = Math.min(...arr);
  let sum = min + max;
  for (let i = min + 1; i < max; i++) {
    sum += i;
  }
  return sum;
}

sumAll([1, 4]);