Given two integers a and b, which can be positive or negative, find the sum of all the integers between and including them and return it. If the two numbers are equal return a or b. code example
Example 1: Given two integers a and b, which can be positive or negative, find the sum of all the integers between including them too and return it. If the two numbers are equal return a or b.
return 2 + getSum(2 + 1, 3)
Example 2: Given two integers a and b, which can be positive or negative, find the sum of all the integers between including them too and return it. If the two numbers are equal return a or b.
const getSum = (a, b) => a === b ? a : getSum(a + (a < b)?1:-1, b);