Skip to content

Instantly share code, notes, and snippets.

@tomatohammado
Created November 21, 2017 14:01
Show Gist options
  • Select an option

  • Save tomatohammado/2b4ccd5ba11cd309bd4e6e590a7fd2a6 to your computer and use it in GitHub Desktop.

Select an option

Save tomatohammado/2b4ccd5ba11cd309bd4e6e590a7fd2a6 to your computer and use it in GitHub Desktop.
old reset-button code
document.querySelector('.reset-button').addEventListener('click', function () {
console.log('Reset button clicked')
// console.log(document.querySelectorAll('.flipped'))
var numCardsInPlay = cardsInPlay.length
console.log('numCardsInPlay: ' + numCardsInPlay)
for (var i = 0; i < numCardsInPlay; i++) {
console.log(cardsInPlay[i])
var currentFlippedCard = document.querySelectorAll('.flipped')[i]
// console.log(document.querySelectorAll('.flipped')[i])
// document.querySelectorAll('.flipped')[i].setAttribute('src', 'images/back.png')
// document.querySelectorAll('.flipped')[i].setAttribute('src', 'images/back.png')
console.log(currentFlippedCard)
currentFlippedCard.setAttribute('src', 'images/back.png')
// cardsInPlay.pop()
// document.querySelectorAll('.flipped')[i].classList.remove('flipped')
}
cardsInPlay = []
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment