Whenever I attempt to run my code on a local server, my laptop slows down and heats up, causing the page not to display correctly.
https://i.sstatic.net/V1eoS.jpg
The source code resembles an infinite loop but I am unable to identify the issue.
deck.addEventListener('click', event => {
const clickTarget = event.target;
if (clickTarget.classList.contains('card') &&
!clickTarget.classList.contains('match') && toggledCards.length < 2 &&
!toggledCards.includes(clickTarget)) {
toggleCard(clickTarget);
addToggleCard(clickTarget);
if (toggledCards.length === 2) {
checkForMatch(clickTarget);
}
}
});