Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Learning JavaScript
- // chapter 14 : Asynchronous Programming
- // makes Promise
- function countdown(seconds) {
- return new Promise(function(resolve, reject) {
- for (let i = seconds; i >= 0; i--) {
- setTimeout(function() {
- if (i > 0) console.log(i + '...');
- else resolve(console.log('GO!'));
- }, (seconds - i) * 1000);
- }
- });
- }
Add Comment
Please, Sign In to add comment