Basic JavaScript: Use Recursion to Create a Range of Numbers question

Tell us what’s happening:
Could any body tell me why my code isnt running ?

Your code so far


function rangeOfNumbers(startNum, endNum) {
if(endNum - startNum === 0) {
return [startNum];
} else {
  var Numbers = rangeOfNumbers (startNum, endNum - 1)
  numbers.push (endNum)
  return Numbers
}
};

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 9; LM-X420) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Mobile Safari/537.36.

Challenge: Use Recursion to Create a Range of Numbers

Link to the challenge:

What do your failing tests say?

The automatic highlighting of Number is telling you that this is a keyword. You should not make a variable name match a keyword. (Not a keyword, its highlighting because it believes this is a class definition? It’s still bad form to name variables with capital letters.)

You should not have a space between your function name and the ()s.

Same comment.

numbers is not a defined variable.

Its still somehow not working could you phrase your answer a little bit easier for foreign dummies (I’m from germany btw)

What does your code look like right now?

function rangeOfNumbers(startNum, endNum) {
if(endNum - startNum === 0) {
return [startNum];
} else {
  var Numbers = rangeOfNumbers(startNum, endNum - 1)
  numbers.push(endNum)
  return Numbers
}
};

I deleted the space between the function and the function thats about all I could understand?

These two are not the same thing - JavaScript is case sensitive

image

If you look in the freeCodeCamp editor, Numbers is highlighted. You will always want your variable names to be lowercase.

Lol I do have to admit I struggle with the syntax even simple syntax the second most but thanks anyways

It’s normal to struggle with syntax - learning a programming is in many ways similar to learning how to speak a new language. It just takes time and practice.

Is it acutally bad to get answers from the the video tutorials you guys provided. I think I sometimes cheated my way through an exercise if I completly didnt know the answer

I would generally avoid using the videos to get answers without understanding what’s going on. Personally, I’d rather see the video solution walkthroughs replaced with videos discussing the concepts on a similar problem. The learning that happens during a video walkthrough of a solution is somewhat limited unless you immediately follow the video with practice.