Hi guys,
I was struggling with this task and didn’t know how to solve it, cause I was always calling
console.log(numbers(1, 5)); to look if i my solution was right but number was not defined
so I was jumping back to the previous Task how it was done and corrected it to that
console.log(rangeOfNumbers(1, 5)); which worked .
I was looking into the solutions after that and found out that the three solutions were with the if statements the same, I am a little it confused if my code was the wrong way to solve it and got lucky that it was solved.
Just wanted to ask if this solution also works for this task
function rangeOfNumbers(startNum, endNum) {
if (startNum > endNum) {
return ;
} else {
var numbers = rangeOfNumbers(startNum, endNum - 1);
numbers.push(endNum);
return numbers;
}
}