karlakmkj

Handle Promise objects

Dec 28th, 2020 (edited)
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. console.log("This is the first line of code in app.js.");
  2. // Keep the line above as the first line of code
  3.  
  4. // Write your code here:
  5. const usingSTO = () => {
  6.   console.log("Today is a happy day!");  //this line will be printed last in the output because of the delay
  7. };
  8.  
  9. setTimeout(usingSTO, 2500); //pass usingSTO() without invoking it
  10.  
  11. // Keep the line below as the last line of code:
  12. console.log("This is the last line of code in app.js.");
  13.  
  14. /*
  15. Output will show:
  16. $ node app.js
  17. This is the first line of code in app.js.
  18. This is the last line of code in app.js.
  19. Today is a happy day!
  20. $
  21. */
Add Comment
Please, Sign In to add comment