Skip to content

Instantly share code, notes, and snippets.

@MinimumViablePerson
Created December 31, 2019 11:24
Show Gist options
  • Save MinimumViablePerson/00642b050e96ac330518f13fcdd4c29d to your computer and use it in GitHub Desktop.
Save MinimumViablePerson/00642b050e96ac330518f13fcdd4c29d to your computer and use it in GitHub Desktop.
Recursion from Scratch - countdown with recursion
// Counting down is:
const countdown = number => {
// Logging `'HAPPY NEW YEAR!'` if we're at zero.
if (number === 0) {
console.log('HAPPY NEW YEAR!')
} else {
// Logging the current number and counting down the next number down otherwise.
console.log(number)
countdown(number - 1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment