Created
December 31, 2019 11:24
-
-
Save MinimumViablePerson/00642b050e96ac330518f13fcdd4c29d to your computer and use it in GitHub Desktop.
Recursion from Scratch - countdown with recursion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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