@Eileenpk
Posted
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 helpful
@coc0dev
Posted
@Eileenpk Hi Eileen, I agree that is a little cleaner instead of switching loop styles. Thanks for pointing that out!