How to use math operations for starting to ending values

**Your code so far**

function sumAll(arr) {
let start=Math.min(arr[0],arr[1])
let end =Math.max(arr[0],arr[1])
let total=0;
for( let i=start; i<=end; i++){
total+=i;
}
return total;
}
console.log(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/100.0.4896.127 Safari/537.36