My event date picker pick dates for every month Javascript calendar

if I want to highlight the 15 august it still highlight 15 of everymonth I tried to remove it by using .remove but it doesn't work here's my code : https://codepen.io/Dennyyan/pen/mdQZYga
Denny
CodePen
mdQZYga
...
4 Replies
Jochem
Jochem16mo ago
Cause that's what you're telling it to do. Here you add just the day of the month to the eventDates array:
eventDates.push(selectedDate.getDate());
eventDates.push(selectedDate.getDate());
then here, you're checking if the eventDates array contains an entry that has the same value as the day of the month in the block:
if (eventDates.includes(parseInt(Days[index].innerText))) {
Days[index].classList.add("event-day");
} else {
Days[index].classList.remove("event-day");
}
if (eventDates.includes(parseInt(Days[index].innerText))) {
Days[index].classList.add("event-day");
} else {
Days[index].classList.remove("event-day");
}
there's no information in the eventDates array about the month or the year for the events, it's just going to be a list of numbers between 1 and 31, and whenever the renderCalendar function runs into a day like that in the current month, it adds the event-day class
Yann2
Yann2OP16mo ago
I see so my logic is entirely wrong how to fix this sir
Jochem
Jochem16mo ago
you'll have to store the entire date and then check against the date instead of just the day like you're doing now
Yann2
Yann2OP16mo ago
Ahhhh i seee thank you very much bro
Want results from more Discord servers?
Add your server