2023-06-19 16:12:59 -07:00
|
|
|
const sumAll = function (number1, number2) {
|
|
|
|
if (number1 < 0 || number2 < 0) return 'ERROR'
|
|
|
|
if (typeof number1 !== 'number' || typeof number2 !== 'number') return 'ERROR'
|
2017-11-24 12:23:16 -08:00
|
|
|
|
2023-06-19 16:12:59 -07:00
|
|
|
let sum = 0
|
|
|
|
|
|
|
|
const start = Math.min(number1, number2)
|
|
|
|
const end = Math.max(number1, number2)
|
|
|
|
|
|
|
|
for (let i = start; i <= end; i++) {
|
|
|
|
sum += i
|
|
|
|
}
|
|
|
|
|
|
|
|
return sum
|
|
|
|
}
|
2017-08-24 06:26:01 -07:00
|
|
|
|
2021-09-11 15:18:19 -07:00
|
|
|
// Do not edit below this line
|
2023-06-19 16:12:59 -07:00
|
|
|
module.exports = sumAll
|