Changed around line 1
+ function generateCalendar() {
+ const calendar = document.getElementById('calendar');
+ const today = new Date();
+ const year = today.getFullYear();
+ const month = today.getMonth();
+
+ const firstDay = new Date(year, month, 1);
+ const lastDay = new Date(year, month + 1, 0);
+
+ for (let day = 1; day <= lastDay.getDate(); day++) {
+ const date = new Date(year, month, day);
+ const dayElement = document.createElement('div');
+ dayElement.className = 'day';
+ dayElement.textContent = day;
+ if (isHoliday(date)) {
+ dayElement.style.backgroundColor = '#ffcccb';
+ }
+ calendar.appendChild(dayElement);
+ }
+ }
+
+ function isHoliday(date) {
+ const holidays = [
+ '2023-01-01', '2023-02-01', '2023-05-01', '2023-10-01'
+ ];
+ return holidays.includes(date.toISOString().split('T')[0]);
+ }
+
+ window.onload = generateCalendar;