# Intermediate Algorithm Scripting - Sum All Numbers in a Range

Tell us what’s happening:
it works on single digit but not on double digits
Please what do u think ?

``````  **Your code so far**
``````
``````function sumAll(arr) {
let z = 0
arr.sort()
for (let i = arr[0] ; i<=arr[1]; i++  ) {
z += i
}
return z
}

it works on single digit but not on double digits  :(
Please what do u think ?

console.log(sumAll([5,10]))
``````
``````  **Your browser information:**
``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36`

Challenge: Intermediate Algorithm Scripting - Sum All Numbers in a Range

Is this doing what you think it is doing? I would add some console.logs to check what’s going on aroung here

1 Like

sorry i dont see it, where is it?

``````**arr.sort((a,b) => a-b)**;
``````

Thank you so much for all replies ,
.sort () missunderstanded me . It accepts the numbers like a string so, i had to show how its done with that function .

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.