Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Control Flow: if, else-if, else
- // We can set conditionals for whether or not a block of code will run
- if (timeOfDay < 12) {
- console.log("Good Morning!");
- } else if (timeOfDay > 11 && timeOfDay < 17) {
- console.log("Good Afternoon!");
- } else if (timeOfDay > 16 && timeOfDay < 21) {
- console.log("Good Evening!");
- } else {
- console.log("Good Night!");
- }
- /* In the above block of code, what is printed to the console changes depending on the time of day. If it's
- earlier than 12 noon it prints 'Good Morning!', if it's between noon and 5pm it prints 'Good Afternoon!', if
- it's between 5pm and 10pm it prints 'Good Evening!', and for any other situation (10pm-12am being the
- remaining time period) it prints 'Good Night!'. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement