Why does the code only work for adding and removing styles in Part (else), but not returning the class when clicked again?
var navDropDown = document.querySelectorAll('.menu-item-has-children > a');
for (let i = 0; i < navDropDown.length; i++) {
navDropDown[i].addEventListener('click', (e) => {
if (navDropDown[i].nextElementSibling.style.display = 'none') {
this.nextElementSibling.style.display = 'block;
} else {
this.nextElementSibling.style.display = 'none';
}
})
}