From 3789f793f83ebf5b677c2a5ba177cc90bae1c4b6 Mon Sep 17 00:00:00 2001 From: khush1611 Date: Mon, 13 Apr 2020 18:41:19 -0400 Subject: [PATCH 1/5] Added clicked card to selectedcards array --- exercise/scripts/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/exercise/scripts/main.js b/exercise/scripts/main.js index b7e7fe7..9d39b1b 100644 --- a/exercise/scripts/main.js +++ b/exercise/scripts/main.js @@ -14,6 +14,7 @@ window.addEventListener('DOMContentLoaded', function() { // collection of selected cards and apply the correct CSS class. if (selectedCards.length < 2) { card.classList.add('is-selected'); + selectedCards.push(card); } // If we have selected two cards, see if they match. From 619367165f71fee866e9b0144e15a8fa281b43b5 Mon Sep 17 00:00:00 2001 From: khush1611 Date: Mon, 13 Apr 2020 19:06:45 -0400 Subject: [PATCH 2/5] Cards do not seem to be compared/matched correctly has been fixed --- exercise/scripts/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercise/scripts/main.js b/exercise/scripts/main.js index 9d39b1b..27d5f24 100644 --- a/exercise/scripts/main.js +++ b/exercise/scripts/main.js @@ -20,7 +20,7 @@ window.addEventListener('DOMContentLoaded', function() { // If we have selected two cards, see if they match. if (selectedCards.length === 2) { var card1 = selectedCards[0]; - var card2 = selectedCards[0]; + var card2 = selectedCards[1]; // If the cards match, add them to the collection of matched cards and // apply the correct CSS class. From 803f22237dc2945df84bcdea0771bb1617856816 Mon Sep 17 00:00:00 2001 From: khush1611 Date: Mon, 13 Apr 2020 19:10:38 -0400 Subject: [PATCH 3/5] The cards are never flipped face down, regardless of whether or not they match. solved --- exercise/scripts/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercise/scripts/main.js b/exercise/scripts/main.js index 27d5f24..65106fa 100644 --- a/exercise/scripts/main.js +++ b/exercise/scripts/main.js @@ -33,7 +33,7 @@ window.addEventListener('DOMContentLoaded', function() { // Regardless of whether or not the cards match, deselect them and reset // the collection of matched cards. card1.classList.remove('is-selected'); - card3.classList.remove('is-selected'); + card2.classList.remove('is-selected'); selectedCards = []; } From 8747e9846688df5de36194db98acc40a3c365d35 Mon Sep 17 00:00:00 2001 From: khush1611 Date: Mon, 13 Apr 2020 19:24:51 -0400 Subject: [PATCH 4/5] it should be >=. solved the issue for The game does not end, even after all the cards have been matched. --- exercise/scripts/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercise/scripts/main.js b/exercise/scripts/main.js index 65106fa..5756472 100644 --- a/exercise/scripts/main.js +++ b/exercise/scripts/main.js @@ -38,7 +38,7 @@ window.addEventListener('DOMContentLoaded', function() { } // If we've matched all the cards, display a message. - if (matchedCards.length > cards.length) { + if (matchedCards.length >= cards.length) { alert('You matched all the cards, nice job!'); } }); From a057c3474fcc5936d5224c516caec37a1be4fb26 Mon Sep 17 00:00:00 2001 From: khush1611 Date: Mon, 13 Apr 2020 19:28:01 -0400 Subject: [PATCH 5/5] adding a . cause the changes didnt went through. --- exercise/scripts/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercise/scripts/main.js b/exercise/scripts/main.js index 5756472..2730de0 100644 --- a/exercise/scripts/main.js +++ b/exercise/scripts/main.js @@ -37,7 +37,7 @@ window.addEventListener('DOMContentLoaded', function() { selectedCards = []; } - // If we've matched all the cards, display a message. + // If we've matched all the cards, display a message.. if (matchedCards.length >= cards.length) { alert('You matched all the cards, nice job!'); }