Understanding the use of recursion to create a countdown

Hello guys, Kindly tell me why the code below doesn’ t work

function countdown(n){
  if(n < 1){
  return [];
  } else {
const countArray = countup( n - 1 );
 countArray.unshift(n);
 return countArray;
  }
}

Do you have a typo? It looks like your code calls countup when you mean to call countdown.

1 Like

Thanks @JeremLT that was actually where the mistake was but I have rectified it and it Worked. Thanks once again

1 Like