(Disclaimer: I'm very new to JS)
Hi everyone,
I'm working on a game where you pick two cards randomly, and depending on the result you'll get a pop-up. I've been following a set of instructions to complete it.
I have two questions:
A. In the console I'm getting an error message:
SyntaxError: missing ; before statement
It's referring to the } else { on Line 7, and I don't know why I'm getting it. Assuming I am missing a ;, where does it go? I figured I'd ask and get another set of eyes on this one.
B. The instructions say I'm supposed to see "User flipped queen" and "User flipped king" in the console, but I'm not.
If the issue in Question 1 is sorted out, will I see them? If not, then what do I do?
- Thanks!
Tsardines
var cards = ["queen", "queen", "king", "king"]; var cardsInPlay = []; var checkForMatch = function() { if (cardsInPlay[0] === cardsInPlay[1]) alert('You found a match!'); } else { alert('Sorry, try again.'); } var flipCard = function(cardId) { console.log("User flipped " + cards[cardId]); cardsInPlay.push(cards[0]); if (cardsInPlay.length === 2) { checkForMatch(); } flipcard(0); flipcard(2);