How to get the last working day of the current month

 /**
         * @description This function is used to find the last day of each month
         * @param {*} year 
         * @param {*} month 
         * @returns lastDay
         */
        function getLastWorkingDayOfMonth(year, month) {
            let lastDay = new Date(year, month, 0);
            while (lastDay.getDay() === 0 || lastDay.getDay() === 6) { // Sunday (0) or Saturday (6)
                lastDay.setDate(lastDay.getDate() - 1); // Move to the previous day
            }
            return lastDay;
        }

Leave a comment

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