Hello i need help to understand the math operation here

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

Challenge: Sum All Numbers in a Range

Link to the challenge:

Can you be more specific about what is confusing you?

1 Like

i am confusing about the Math operation

Sum All Numbers in a Range

Do you mean the Math module, being used here?

let start=Math.min(arr[0],arr[1])

It is a JS object with various properties and methods. When in doubt, read the documentation.

Right, it a function to take all the numbers in a range, and sum them, or add them together.

If your range is 2 to 5, then you would add together the numbers 2, 3, 4, and 5. The answer would be 14.