Created
February 19, 2018 11:13
-
-
Save chalu/0a16c56fa3b1bb03e22a65a3b3334f80 to your computer and use it in GitHub Desktop.
A number of countdown implementations to review
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
const countdownA = (limit) => { | |
for(let i = limit; i >= 1; i--) { | |
console.log('Now @ ' + i); | |
} | |
}; | |
const countdownB = (limit) => { | |
console.log('Now @ ' + limit); | |
if (limit === 1) return 1; | |
countdownB(limit); | |
}; | |
const countdownC = (limit) => { | |
console.log('Now @ ' + limit); | |
if (limit === 1) return 1; | |
countdownC(limit - 1); | |
}; | |
const countdownD = (limit) => { | |
console.log('Now @ ' + limit); | |
if (limit = 1) return 1; | |
countdownD(limit--); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment