Guest User

Untitled

a guest
Feb 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. // Learning JavaScript
  2. // chapter 14 : Asynchronous Programming
  3.  
  4. // makes Promise
  5.  
  6. function countdown(seconds) {
  7. return new Promise(function(resolve, reject) {
  8. for (let i = seconds; i >= 0; i--) {
  9. setTimeout(function() {
  10. if (i > 0) console.log(i + '...');
  11. else resolve(console.log('GO!'));
  12. }, (seconds - i) * 1000);
  13. }
  14. });
  15. }
Add Comment
Please, Sign In to add comment