Design comparison
SolutionDesign
Solution retrospective
Hello 👋, FrontendMentor Community,
This is the code I implemented to clear all notifications in ./js/main.js:
const allRedDots = document.querySelectorAll(".red-dot"); //get all red dots
const unreadNotificationsCounter = document.querySelector(
"#unread-notifications-counter"
); //get the counter of unread notifications
unreadNotificationsCounter.textContent = allRedDots.length; //display the number of unread notifications
const btnClearAll = document.querySelector(".btn-clear-all"); //get the button to clear all notifications
btnClearAll.addEventListener("click", clearAllNotifications); //add event listener to the button to clear all notifications
function clearAllNotifications() {
allRedDots.forEach((redDot) => redDot.remove()); //remove all red dots
unreadNotificationsCounter.textContent = 0; //set the counter of unread notifications to 0
}
Happy to hear feedback and advice ✌️
Community feedback
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