I need to know how the code Works? The way of Implementaion

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

function countup(n) {
if (n < 1) {
  return [];
} else {
  const countArray 
  countArray.push(n);
  countArray= countup(n - 1);
  return countArray;
}
}
console.log(countup(5));
  **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.45 Safari/537.36

Challenge: Use Recursion to Create a Countdown

Link to the challenge:

HI @rahulsteverz3000 !

Welcome to the forum!

It looks like you are asking for help on the example code.
Right now you have an error in your example code.
This is what the original looks like

function countup(n) {
  if (n < 1) {
    return [];
  } else {
    const countArray = countup(n - 1);
    countArray.push(n);
    return countArray;
  }
}
console.log(countup(5));

Recursion is a tricky concept to understand at first.
I would suggest first watching this video to help with your understanding.

Then you can revisit the example code and understand how it works.

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