Skip to content

Instantly share code, notes, and snippets.

@petergi
Created February 25, 2026 19:19
Show Gist options
  • Select an option

  • Save petergi/2a52db79cb8c66de01d044dd24132c45 to your computer and use it in GitHub Desktop.

Select an option

Save petergi/2a52db79cb8c66de01d044dd24132c45 to your computer and use it in GitHub Desktop.
Checks if the given date is a weekday.
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