Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```javascript
- function delay(callback, waitTime) {
- function waitifyFunc() {
- return setTimeout(callback, waitTime);
- }
- return waitifyFunc;
- }
- // UNCOMMENT THE CODE BELOW TO TEST DELAY
- let count = 0;
- const delayedFunc = delay(() => count++, 1000);
- delayedFunc();
- console.log(count); // should print '0'
- setTimeout(() => console.log(count), 1000); // should print '1' after 1 second
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement