can anyone tell me which piece of code is not working as intended and an explanation as to why.
Trying to take any 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.
Note: a and b are not ordered!
More can be found about the question in the link below.
https://www.codewars.com/kata/55f2b110f61eb01779000053/train/javascript
function getSum( a,b ){
let count = 0;
if(a>b){
let greaterNum = a;
let lesserNum = b;
count = lesserNum;
for(lesserNum; lesserNum<greaterNum; lesserNum++){
count += 1;
}
return count;
}else if(a<b){
let greaterNum = b;
let lesserNum = a;
count = lesserNum;
for(lesserNum; lesserNum<greaterNum; lesserNum++){
count += 1;
}
return count;
}else if (a==b){
return a;
}
}