Last active
October 13, 2015 16:17
-
-
Save imwithsam/4f9ead7e0bf58bf0f871 to your computer and use it in GitHub Desktop.
Countdown
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
function countdown(seconds, callback){ | |
var i = setInterval(function() { | |
if (typeof callback === 'function') { | |
callback(seconds--); | |
} else { | |
console.log(seconds--); | |
} | |
if (seconds === -1) { | |
clearInterval(i); | |
} | |
}, 1000); | |
} | |
countdown(5); | |
countdown(10, function (i) { | |
console.log('THIS IS MY CUSTOM CALLBACK!!!', i); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment