const buttons = document.getElementsByTagName("button"); const articles = document.getElementsByTagName("article"); document.getElementById("filter").classList.remove("hidden"); for (let i = 0; i < buttons.length; ++i) if (buttons[i].name !== "") buttons[i].addEventListener("click", e => { for (let j = 0; j < articles.length; ++j) if (articles[j].id.startsWith(e.target.name) || e.target.name === "all") articles[j].classList.remove("hidden"); else articles[j].classList.add("hidden"); });