Design comparison
SolutionDesign
Solution retrospective
I welcome any feedback!
Community feedback
- @EileenpkPosted over 2 years ago
Excellent work, your code is very clean! Could you have used a forEach instead of running a loop on dropDown?
dropDown.forEach((el) => { el.addEventListener('click', () => { if (el.classList.contains('active')) { dropDown.forEach((drop, index) => { el.classList.remove('active') }) } else { dropDown.forEach((drop, index) => { dropDown[index].classList.remove('active') }) el.classList.add('active') } }) })
Marked as helpful0@coc0devPosted over 2 years ago@Eileenpk Hi Eileen, I agree that is a little cleaner instead of switching loop styles. Thanks for pointing that out!
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