what is the sum of the range of numbers from 1 to 10 code example
Example: Sum All Numbers in a Range
const sumAll = arr => {
let maxNumber = Math.max(...arr)
let minNumber = Math.min(...arr)
let numbersArray = []
for(let i = minNumber; i <= maxNumber; i++){
numbersArray.push(i)
}
return numbersArray.reduce((acc, cur) => acc + cur, 0)
}
sumAll([1, 4]);