-
-
Save Developerayo/bfd6961c2d2c89142e6bfc24b4c38778 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