Created
May 1, 2019 18:35
-
-
Save mstan/261d221f9519e3a00467992728957d97 to your computer and use it in GitHub Desktop.
Day of week
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| getDay returns a number that represents the day of the week. | |
| In programming, we never start at 1 when counting. We start at 0! | |
| Therefore, the seven days of the week are 0-6 (not 1-7). | |
| 0 is Sunday | |
| 1 is Monday | |
| 2 is Tuesday | |
| 3 is Wednesday | |
| 4 is Thursday | |
| 5 is Friday | |
| 6 is Saturday | |
| */ | |
| let day = new Date().getDay(); | |
| switch (day) { | |
| case 1: | |
| case 2: | |
| case 3: | |
| case 4: | |
| case 5: | |
| console.log("Today is a weekday") | |
| break; | |
| case 0: | |
| case 6: | |
| console.log("Today is a weekend day"); | |
| break; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment