Basic JavaScript - Use Recursion to Create a Range of Numbers

Tell us what’s happening:
hey guys why my function doesn’t work? the || is wrong to connect both boolean?

Your code so far

function rangeOfNumbers(startNum, endNum) {
  if ( n < 1){
  return []
  }
  else{
  const arr = x(n - 1)
  arr.unshift(startNum) || arr.push(endNum)
  return arr

  }
};

console.log(1,4)

Your browser information:

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

Challenge: Basic JavaScript - Use Recursion to Create a Range of Numbers

Link to the challenge:

You aren’t calling rangeOfNumbers inside of rangeOfNumbers so it isn’t a recursive function.

Also, I’m not sure what you want the || to do, but it doesn’t do that.

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