Tell us what’s happening:
Hello guys I am having a couple doubt about my code, i have been using repl.it and I have noticed that when I console.log(arr)
I get [6] [7] [8] [9] instead of [6,7,8,9] and when I return arr
I only get [9].
Any help on this would be nice.
Your code so far
function rangeOfNumbers(startNum, endNum) {
if (startNum <= endNum ){
var arr = [];
var range = (endNum - startNum + 1) + (startNum - 1) ;
arr.unshift(range);
rangeOfNumbers(startNum, endNum - 1)
return arr // console.log(arr)
}
};
rangeOfNumbers(6, 9)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0
.
Challenge: Use Recursion to Create a Range of Numbers
Link to the challenge: