I'm trying to make a nav bar show when a button(icon) is clicked and disappear when it is clicked again. The first part works where it shows but then when clicked again, nothing happens. I can't figure out why the second part is being ignored. Thank you
let nav = document.querySelector("nav");
let icon = document.querySelector(".mobile-icon");
console.log(nav);
icon.addEventListener("click", showMenu)
function showMenu() {
if (nav.style.display = "none"){
nav.style.display = "block";
} else {
nav.style.display = "none";
}
}