Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. // Control Flow: if, else-if, else
  2.  
  3. // We can set conditionals for whether or not a block of code will run
  4.  
  5. if (timeOfDay < 12) {
  6. console.log("Good Morning!");
  7. } else if (timeOfDay > 11 && timeOfDay < 17) {
  8. console.log("Good Afternoon!");
  9. } else if (timeOfDay > 16 && timeOfDay < 21) {
  10. console.log("Good Evening!");
  11. } else {
  12. console.log("Good Night!");
  13. }
  14.  
  15. /* In the above block of code, what is printed to the console changes depending on the time of day. If it's
  16. earlier than 12 noon it prints 'Good Morning!', if it's between noon and 5pm it prints 'Good Afternoon!', if
  17. it's between 5pm and 10pm it prints 'Good Evening!', and for any other situation (10pm-12am being the
  18. remaining time period) it prints 'Good Night!'. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement