Design comparison
Solution retrospective
any suggestions on how to improve are welcome, Please SHARE.
Community feedback
- @JeuriMorelPosted about 1 year ago
Clicking on a notification makes the counter go up indefinitely but I'm pretty sure that the counter is supposed to represent the number of unread notifications. So it should start with how many of the notifications are in the unread state and decrease by one whenever those notifications are marked as read.
0@iamcelestinoPosted about 1 year agoThanks a lot.
I made all the change you suggested. but I the didn't get success, stopping the counter.
can you give an Idea?
how did you see the way I wrote my JS code is that the good way, is the room for improvements apart from the one you mentioned?
@JeuriMorel
0@JeuriMorelPosted about 1 year ago@iamcelestino
I took a look at your JS and it looks like you're always decreasing count every time the notification is clicked. I would add an
if
statement to run the code only if the notification is unread. I would rearrange your event listener function to look more like this:notifications.forEach(notification => { notification.addEventListener("click", () => { const marker = notification.childNodes[3].childNodes[1].firstChild.nextSibling.childNodes[2]; if (marker.classList.contains("marker")) { count--; countReadNotification(count); notification.classList.add("change__color"); marker.classList.remove("marker"); } }) });
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord