I have built this function hoping to sum the numbers I assign to the array. However, this function gives not only the sum of the numbers I put in the array but also those in between them and I am not sure how to fix that
 function sum(arr) {
    let total = 0;
    let start = Math.min(arr[0], arr[1]);
    let end = Math.max(arr[0], arr[1]);
    for (let i = start; i <= end; i++) {
      total += i;
    }
    return total;
  }
for example this console.log(sum([2,4])); gives 9 and not 6
Also, I cannot seem to find a way to be able to add more than two numbers to my array
