Skip to content

Check if a date is a weekday in TypeScript

Advertisements
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  Longest Substring Without Repeating Characters - Leetcode Challenge - Python Solution

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.