Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. ```javascript
  2. function delay(callback, waitTime) {
  3. function waitifyFunc() {
  4. return setTimeout(callback, waitTime);
  5. }
  6. return waitifyFunc;
  7. }
  8.  
  9. // UNCOMMENT THE CODE BELOW TO TEST DELAY
  10. let count = 0;
  11. const delayedFunc = delay(() => count++, 1000);
  12. delayedFunc();
  13. console.log(count); // should print '0'
  14. setTimeout(() => console.log(count), 1000); // should print '1' after 1 second
  15. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement