Skip to content

Check if a date is a weekday in TypeScript

const isWeekday = (d: Date): boolean => d.getDay() % 6 !== 0;

isWeekday(new Date(2022, 2, 10)); // -> true
isWeekday(new Date(2021, 5, 8)); // -> false
See also  Finding nth root of a number in JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.