Game rules:
- don't click/choose the same item multiple times.
- If your 2 consecutive choices match, you score a point.
Play the game
Learn JavaScript by Building Games 2
Initial main challenge is to shuffle/sort all the items randomly.
cardArray.sort(() => 0.5 - Math.random()) //cardArray is the array that contains all the items
Other JavaScript methods and properties used :
.querySelector()
.Math.random()
.length
.createElement()
.setAttribute()
.append()
.getAttribute()
alert()
.push()
setTimeout()
.querySelectorAll()
.removeEventListener()
.textContent