Are any of these versions correct? I would like the icon to change after clicking the menu. in Javascript these are my beginnings and I don't know what is right
const menu = document.querySelector('#menu-btn');
menu.onclick = () => {
menu.classList.toggle('fa-times');
navbar.classList.toggle('active');
};
or this
const menu = document.querySelector('#menu-btn');
menu.addEventListener('click', function(event){
menu.classList.toggle('fa-times');
navbar.classList.toggle('active');
});