MichaelPachec0 / nodejs-project-night

Project night for May 27 2022
MIT License
5 stars 12 forks source link

REFACTOR: Event handler should be contained in a function. #48

Closed JoeDravarol closed 1 year ago

JoeDravarol commented 2 years ago

The code below should be refactor into its own function so that we can call it on game start or game reset.

// this function toggles the pokemon card on click
let cards = document.querySelectorAll('.card');

cards.forEach(card => {
    card.addEventListener('click', ()=>{
        if(!(card.classList.contains('visible'))){
            card.className = 'card visible'
        }else{
            card.classList = 'card'
        }
    })
})