-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
29 lines (24 loc) · 761 Bytes
/
script.js
File metadata and controls
29 lines (24 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*//import { levelConfigurations } from './level.js';
let flippedCards = [];
// Toggles the flipped state of the card
function flipCard(event){
const clickedCard = event.target;
clickedCard.classList.toggle('flipped');
flippedCards.push(clickedCard);
if (flippedCards.length === 2){
if (flippedCards[0].dataset.card === flippedCards[1].dataset.card){
flippedCards = [];
} else{
setTimeout(() => {
flippedCards.forEach(card => card.classList.remove('flipped'));
flippedCards = [];
}, 1000);
}
}
}
//Selects card elements(*)
const cards = document.querySelectorAll('.card');
//Event listener will detect the click interactions
cards.forEach(card => {
card.addEventListener('click', flipCard);
}); */