I am happy you find the content useful 😊. For more such content Subscribe to the channel and Here is the playlist of Frontend Machine Coding Interview Problems ru-vid.com/group/PLBygUld3s6x8sI_H8UYROVMIVcuxUre1e
Thanks for the code, I did some modifications. let starRating = document.querySelectorAll(".star"); let ratingCount = document.getElementById("count"); starRating.forEach((star, index) => { star.addEventListener("click", () => { if (star.classList.contains("active")) { for (let i = starRating.length-1; i > index; i--) { starRating[i].classList.remove("active"); } } else { for (let i = 0; i < index + 1; i++) { starRating[i].classList.add("active"); } } let activeStars = document.querySelectorAll(".star.active").length; ratingCount.innerHTML = `Rating Count : ${activeStars}`; }); }); starRating.forEach((star, index) => { star.addEventListener("mouseover", () => { for (let i = 0; i < index + 1; i++) { starRating[i].classList.add("hovered"); } }); }); starRating.forEach((star, index) => { star.addEventListener("mouseout", () => { for (let i = 0; i < index + 1; i++) { starRating[i].classList.remove("hovered"); } }); });