This does not work because you are missing a parameter in a recursive call
It should be like
function rangeRecursive(num, num2) { return (num2 >= num) ? rangeRecursive(num , num2 - 1).concat(num2) : [] }
Also pay attention to the changed condition on the ternary, otherwise it stops at 1 and does not contact it. Either you can use >= or the following
return num2 > num ? rangeRecursive(num, num2 - 1).concat(num2) : [num]
source share