Created
February 25, 2026 19:19
-
-
Save petergi/2a52db79cb8c66de01d044dd24132c45 to your computer and use it in GitHub Desktop.
Checks if the given date is a weekday.
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
| Checks if the given date is a weekday. | |
| - Use `Date.prototype.getDay()` to check weekday by using a modulo operator (`%`). | |
| - Omit the argument, `d`, to use the current date as default. | |
| const isWeekday = (d = new Date()) => d.getDay() % 6 !== 0; | |
| isWeekday(); // true (if current date is 2019-07-19) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment