samedi 11 août 2018

Why is my condition always met?

I created my var outside the function, then in the function I add++ only when cards are flipped. my console writes cardserial=0, but still the "return" works and the rest of my function doesn't work at all. why does the if (cardserial == 2 ); return true?

var cardserial = 0;

// This function is called whenever the user click a card
function cardClicked(elCard) {
console.log(cardserial)

if (cardserial == 2 ); {
console.log('prevent triple card flip')
return; 
} 

if (typeof startTime === 'undefined') {
...
 var card2 = elCard.getAttribute('data-card');
    cardserial++;
    console.log('Second')
...

Aucun commentaire:

Enregistrer un commentaire