Merge pull request #1003 from 30-seconds/simplify-isWeekday

Update isWeekday.md
This commit is contained in:
Angelos Chalaris
2019-07-20 12:35:43 +03:00
committed by GitHub

View File

@ -3,11 +3,11 @@
Results in a boolean representation of a specific date.
Pass the specific date object firstly.
Use `Date.getDay()` to check weekday then return a boolean.
Use `Date.getDay()` to check weekday by using a modulo operator and then returning a boolean.
```js
const isWeekday = (t = new Date()) => {
return t.getDay() >= 1 && t.getDay() <= 5;
return t.getDay() % 6 !== 0;
};
```