Can someone explain how this recursion works?
If i understand correctly if startNum is equal to endNum then if its true then return ? array [startNum or endNum] it is equal so which ever floats the boat.
else if false : then call itself. Now this is the confusing bit when it is calling itself is it counting down or - 1 from endNum or from both? Another confusing bit if its - 1 from endNum does that mean the first input is already - 1 ( -1 below endNum)that is why we need to concat(endNum)?
**Your code so far**
function rangeOfNumbers(startNum, endNum) {
return startNum === endNum
? [startNum]
: rangeOfNumbers(startNum, endNum - 1).concat(endNum);
};
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36
.
Challenge: Use Recursion to Create a Range of Numbers
Link to the challenge: