Don't know why it's working that way

It’s funny because even that returns correlative numbers from startNum to endNum it puts them all together within ’ ', instead of comma-separated.

For example:
rangeOfNumbers (2, 6)
returns [ ‘23456’ ]
instead of [ 2, 3, 4, 5, 6 ].
anyone knows why is that?

  **Your code so far**
function rangeOfNumbers(startNum, endNum) {
if (startNum > endNum) {
  return [];
var myNum = startNum + rangeOfNumbers(startNum + 1, endNum);
let arr = [];
return arr;

console.log(rangeOfNumbers(2, 6))
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.66 Safari/537.36 Edg/103.0.1264.44

Challenge: Use Recursion to Create a Range of Numbers

Link to the challenge:

you are causing that here - that is not the way to add a number to an array

Thank you! I’ve finally solved it, although I still have to get a better understanding of it. It’s like the feeling of getting the solution more by accident than a good comprehension of it.
Anyway I appreciate your help so much!!

so, delete the solution, and try to solve it again in a couple of days! if you understand, you will be able to solve it again

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.