Basic Javascript recursion challenge

I’m having trouble with the final question on recursion on basic javascript.
My code is:

function rangeOfNumbers(startNum, endNum) {
if (endNum===startNum) {
  return [startNum];
} else {
  var num = rangeofNumbers[startNum, endNum-1];
  return num;

My error is not returning an array - i thought this would be declared by var and the basecase.

  **Your browser information:**

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

Challenge: Use Recursion to Create a Range of Numbers

Link to the challenge:

Two things:

  • You aren’t capitalizing the function correctly.
  • Are you sure you use square brackets to invoke a function?
1 Like

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