diff --git a/css/normalize.css b/css/normalize.css new file mode 100755 index 00000000..192eb9ce --- /dev/null +++ b/css/normalize.css @@ -0,0 +1,349 @@ +/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */ + +/* Document + ========================================================================== */ + +/** + * 1. Correct the line height in all browsers. + * 2. Prevent adjustments of font size after orientation changes in iOS. + */ + +html { + line-height: 1.15; /* 1 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/* Sections + ========================================================================== */ + +/** + * Remove the margin in all browsers. + */ + +body { + margin: 0; +} + +/** + * Render the `main` element consistently in IE. + */ + +main { + display: block; +} + +/** + * Correct the font size and margin on `h1` elements within `section` and + * `article` contexts in Chrome, Firefox, and Safari. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/* Grouping content + ========================================================================== */ + +/** + * 1. Add the correct box sizing in Firefox. + * 2. Show the overflow in Edge and IE. + */ + +hr { + box-sizing: content-box; /* 1 */ + height: 0; /* 1 */ + overflow: visible; /* 2 */ +} + +/** + * 1. Correct the inheritance and scaling of font size in all browsers. + * 2. Correct the odd `em` font sizing in all browsers. + */ + +pre { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} + +/* Text-level semantics + ========================================================================== */ + +/** + * Remove the gray background on active links in IE 10. + */ + +a { + background-color: transparent; +} + +/** + * 1. Remove the bottom border in Chrome 57- + * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. + */ + +abbr[title] { + border-bottom: none; /* 1 */ + text-decoration: underline; /* 2 */ + text-decoration: underline dotted; /* 2 */ +} + +/** + * Add the correct font weight in Chrome, Edge, and Safari. + */ + +b, +strong { + font-weight: bolder; +} + +/** + * 1. Correct the inheritance and scaling of font size in all browsers. + * 2. Correct the odd `em` font sizing in all browsers. + */ + +code, +kbd, +samp { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} + +/** + * Add the correct font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` elements from affecting the line height in + * all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sub { + bottom: -0.25em; +} + +sup { + top: -0.5em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove the border on images inside links in IE 10. + */ + +img { + border-style: none; +} + +/* Forms + ========================================================================== */ + +/** + * 1. Change the font styles in all browsers. + * 2. Remove the margin in Firefox and Safari. + */ + +button, +input, +optgroup, +select, +textarea { + font-family: inherit; /* 1 */ + font-size: 100%; /* 1 */ + line-height: 1.15; /* 1 */ + margin: 0; /* 2 */ +} + +/** + * Show the overflow in IE. + * 1. Show the overflow in Edge. + */ + +button, +input { /* 1 */ + overflow: visible; +} + +/** + * Remove the inheritance of text transform in Edge, Firefox, and IE. + * 1. Remove the inheritance of text transform in Firefox. + */ + +button, +select { /* 1 */ + text-transform: none; +} + +/** + * Correct the inability to style clickable types in iOS and Safari. + */ + +button, +[type="button"], +[type="reset"], +[type="submit"] { + -webkit-appearance: button; +} + +/** + * Remove the inner border and padding in Firefox. + */ + +button::-moz-focus-inner, +[type="button"]::-moz-focus-inner, +[type="reset"]::-moz-focus-inner, +[type="submit"]::-moz-focus-inner { + border-style: none; + padding: 0; +} + +/** + * Restore the focus styles unset by the previous rule. + */ + +button:-moz-focusring, +[type="button"]:-moz-focusring, +[type="reset"]:-moz-focusring, +[type="submit"]:-moz-focusring { + outline: 1px dotted ButtonText; +} + +/** + * Correct the padding in Firefox. + */ + +fieldset { + padding: 0.35em 0.75em 0.625em; +} + +/** + * 1. Correct the text wrapping in Edge and IE. + * 2. Correct the color inheritance from `fieldset` elements in IE. + * 3. Remove the padding so developers are not caught out when they zero out + * `fieldset` elements in all browsers. + */ + +legend { + box-sizing: border-box; /* 1 */ + color: inherit; /* 2 */ + display: table; /* 1 */ + max-width: 100%; /* 1 */ + padding: 0; /* 3 */ + white-space: normal; /* 1 */ +} + +/** + * Add the correct vertical alignment in Chrome, Firefox, and Opera. + */ + +progress { + vertical-align: baseline; +} + +/** + * Remove the default vertical scrollbar in IE 10+. + */ + +textarea { + overflow: auto; +} + +/** + * 1. Add the correct box sizing in IE 10. + * 2. Remove the padding in IE 10. + */ + +[type="checkbox"], +[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Correct the cursor style of increment and decrement buttons in Chrome. + */ + +[type="number"]::-webkit-inner-spin-button, +[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Correct the odd appearance in Chrome and Safari. + * 2. Correct the outline style in Safari. + */ + +[type="search"] { + -webkit-appearance: textfield; /* 1 */ + outline-offset: -2px; /* 2 */ +} + +/** + * Remove the inner padding in Chrome and Safari on macOS. + */ + +[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * 1. Correct the inability to style clickable types in iOS and Safari. + * 2. Change font properties to `inherit` in Safari. + */ + +::-webkit-file-upload-button { + -webkit-appearance: button; /* 1 */ + font: inherit; /* 2 */ +} + +/* Interactive + ========================================================================== */ + +/* + * Add the correct display in Edge, IE 10+, and Firefox. + */ + +details { + display: block; +} + +/* + * Add the correct display in all browsers. + */ + +summary { + display: list-item; +} + +/* Misc + ========================================================================== */ + +/** + * Add the correct display in IE 10+. + */ + +template { + display: none; +} + +/** + * Add the correct display in IE 10. + */ + +[hidden] { + display: none; +} diff --git a/css/reset.css b/css/reset.css new file mode 100755 index 00000000..2ee7ab0f --- /dev/null +++ b/css/reset.css @@ -0,0 +1,47 @@ +/* http://meyerweb.com/eric/tools/css/reset/ + v2.0 | 20110126 + License: none (public domain) +*/ +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} diff --git a/css/style.css b/css/style.css new file mode 100755 index 00000000..4f93fdce --- /dev/null +++ b/css/style.css @@ -0,0 +1,63 @@ +/* Box Model Hack */ +* { + box-sizing: border-box; +} + +/* Clear fix hack */ +.clearfix:after { + content: "."; + display: block; + clear: both; + visibility: hidden; + line-height: 0; + height: 0; +} + +.clear { + clear: both; +} + +/****************************************** +/* BASE STYLES +/*******************************************/ + +body { + +} + +.row { + display: flex; + flex-wrap: wrap; + justify-content: center; + gap: 20px; +} + +.card { + border: 2px solid lightgray; + border-radius: 20px; + height: 150px; + width: 150px; +} + +.card:hover { + background: darkcyan; + cursor: pointer; +} + + + + +/****************************************** +/* LAYOUT +/*******************************************/ +header { + +} + +footer { + +} + +/****************************************** +/* ADDITIONAL STYLES +/*******************************************/ diff --git a/index.html b/index.html new file mode 100755 index 00000000..c088e72b --- /dev/null +++ b/index.html @@ -0,0 +1,35 @@ + + + + + + + + + Blank Template + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+ +

+ + + + + diff --git a/js/main.js b/js/main.js new file mode 100644 index 00000000..10c7d32a --- /dev/null +++ b/js/main.js @@ -0,0 +1,577 @@ +/* + +LOGIC: +X. Take 2 cards as parameters for the function. Possibly make a class to catch the user input? Or just make 2 variables? +0. Have event listeners for each card. If a card is clicked add a style to mimic the card being flipped +0. Use conditionals to match the parameters to a winning set of conditionals +0. If no winning conditionals hide both parameters (cards that were clicked) + +ISSUES: +1. Card reveal- Should I have "2 cards" layered on top of one another then remove the card on top to reveal the card on the bottom ---OR--- Add and remove the image side every time the user clicks on a card +- The 2 layered card idea started to get complicated, so I switched to adding and removing images on the cards + +OUT OF SCOPE: +0. Shuffle the cards + +*/ + + + + + + + + + + + + + + + +// HOLD CLICKS?- not sure if storing clicks in parameters is effective. Let's just keep track of which cards are 'faced up' +// class clickHold { +// constructor(clickOne, clickTwo) { +// this.clickOne = clickOne, +// this.clickTwo = clickTwo +// } +// } + +// let clickOne = new clickHold(true, false) // false means no, while true means that value exists in the variable +// let clickTwo = new clickHold(false, true) + +// let currentFace = " " +let flippedCards = []; // To track currently flipped cards + +// MATCH CONDITIONS +function matchCondition() { + + // VALUE INPUTS- store the box value + // let dog1 = document.getElementById('dog1').innerText; + // let dog2 = document.getElementById('dog2').innerText; + // let rabbit1 = document.getElementById('rabbit1').innerText; + // let rabbit2 = document.getElementById('rabbit2').innerText; + // let fox1 = document.getElementById('fox1').innerText; + // let fox2 = document.getElementById('fox2').innerText; + // let frog1 = document.getElementById('frog1').innerText; + // let frog2 = document.getElementById('frog2').innerText; + // let panda1 = document.getElementById('panda1').innerText; + // let panda2 = document.getElementById('panda2').innerText; + +// TROUBLESHOOTING => STALLED MATCHES- MATCH BEFORE STALL + // Foxes- after one match (rabbits) + + // Rabbits- after one match (dogs) + // Rabbits- after 2 matches (pandas, dogs) + // Rabbits- after 2 matches (foxes, dogs) + + // Pandas- after one match (frogs) + // Pandas- after one match (foxes) + // Pandas- after one match (dogs) + + + // CONDITIONALS + // if ((dog1 === "🐶") && (dog2 === "🐶")){ + // console.log("Dogs are a match") + // // document.querySelector('h2').innerText = "It's a Match!" + // // document.getElementById('dog1').style.display = "none" + // // document.getElementById('dog2').style.display = "none" + // document.getElementById('dog1').remove(); + // document.getElementById('dog2').remove(); + // currentFace = " " + // } else if ((rabbit1 === "🐰") && (rabbit2 === "🐰")) { + // console.log("Rabbits are a match") + // // document.getElementById('rabbit1').style.display = "none" + // // document.getElementById('rabbit2').style.display = "none" + // document.getElementById('rabbit1').remove(); + // document.getElementById('rabbit2').remove(); + // currentFace = " " + // } else if ((fox1 === "🦊") && (fox2 === "🦊")) { + // console.log("Foxes are a match") + // // document.getElementById('fox1').style.display = "none" + // // document.getElementById('fox2').style.display = "none" + // document.getElementById('fox1').remove(); + // document.getElementById('fox2').remove(); + // currentFace = " " + // } else if ((frog1 === "🐸") && (frog2 === "🐸")) { + // console.log("Frogs are a match") + // // document.getElementById('frog1').style.display = "none" + // // document.getElementById('frog2').style.display = "none" + // document.getElementById('frog1').remove(); + // document.getElementById('frog2').remove(); + // currentFace = " " + // } else if ((panda1 === "🐼") && (panda2 === "🐼")) { + // console.log("Pandas are a match") + // // document.getElementById('panda1').style.display = "none" + // // document.getElementById('panda2').style.display = "none" + // document.getElementById('panda1').remove(); + // document.getElementById('panda2').remove(); + // currentFace = " " + // } + // else { + // console.log("Not a match") // The player keeps playing the game until they trigger a winning conditionn + // } + + + +// Check for matches +if (flippedCards.length === 2) { // Only 2 cards in this array + const [firstCard, secondCard] = flippedCards; // Giving parameters to the array + + const firstValue = firstCard.innerText; // First card will be populated by what was clicked + const secondValue = secondCard.innerText; // Second card will be populated by what was clicked + + // if (firstValue === secondValue) { // Check if they match + // console.log(`${firstValue}s are a match`); + // firstCard.dataset.matched = "true"; // Mark as matched + // secondCard.dataset.matched = "true"; // Mark as matched + // firstCard.remove(); // Remove matched cards from DOM + // secondCard.remove(); + // flippedCards = []; // Clear the flipped cards array + // checkGameCompletion(); + // } else { + // console.log("Not a match"); + // // If not a match, flip cards back + // setTimeout(() => { + // firstCard.innerText = ""; // Reset to hidden state + // secondCard.innerText = ""; // Reset to hidden state + // flippedCards = []; // Clear the array + // }, 1000); // Wait for 1 second before flipping back + // } + + if ((firstValue === "🐶" && secondValue === "🐶")) { // If both cards in the flipped card array are dogs then they're a match + console.log("Dogs are a match"); + firstCard.remove(); + console.log(`Removed: ${firstCard.id}`); // The dog1 card is removed from DOM after match + secondCard.remove(); + console.log(`Removed: ${secondCard.id}`); // The dog2 card is removed from DOM after match + flippedCards = []; + } else if ((firstValue === "🐰" && secondValue === "🐰")) { + console.log("Rabbits are a match"); + firstCard.remove(); + secondCard.remove(); + flippedCards = []; + } else if ((firstValue === "🦊" && secondValue === "🦊")) { + console.log("Foxes are a match"); + firstCard.remove(); + secondCard.remove(); + flippedCards = []; + } else if ((firstValue === "🐸" && secondValue === "🐸")) { + console.log("Frogs are a match"); + firstCard.remove(); + secondCard.remove(); + flippedCards = []; + } else if ((firstValue === "🐼" && secondValue === "🐼")) { + console.log("Pandas are a match"); + firstCard.remove(); + secondCard.remove(); + flippedCards = []; + } else { + // If not a match, flip cards back after a second delay + setTimeout(() => { + firstCard.innerText = ""; // Reset first card + secondCard.innerText = ""; // Reset second card + flippedCards = []; // Clear the array + }, 1000); // 1 second delay + } + + + } // End of flipped cards if statement + +} + +function checkGameCompletion() { + const cards = document.querySelectorAll('.card'); + const remainingCards = Array.from(cards).filter(card => card.innerText !== ""); + + console.log(`Remaining cards: ${remainingCards.length}`); + console.log('Remaining card elements:', remainingCards.map(card => card.outerHTML)); + + if (remainingCards.length === 0) { + console.log("All cards matched! Game Over!"); + document.querySelector('h2').innerText = "Congratulations! You've matched all cards!"; + } +} + +// function cardClick(cardId, animalEmoji) { +// document.getElementById(cardId).addEventListener('click', function() { +// const value = this; // Reference to the clicked card + +// // Check if the card is already matched or flipped down +// if (value.innerText === '' || value.dataset.matched) { +// console.log("Card already matched or flipped down"); +// return; // Ignore if the card is already matched or flipped down +// } + +// console.log(`${animalEmoji} clicked`); +// value.innerText = animalEmoji; // Show the card +// flippedCards.push(value); // Track flipped card + +// if (flippedCards.length === 2) { +// matchCondition(); +// } +// }); +// } + +// // Setup event listeners for each card +// cardClick('dog1', '🐶'); +// cardClick('dog2', '🐶'); +// cardClick('rabbit1', '🐰'); +// cardClick('rabbit2', '🐰'); +// cardClick('fox1', '🦊'); +// cardClick('fox2', '🦊'); +// cardClick('frog1', '🐸'); +// cardClick('frog2', '🐸'); +// cardClick('panda1', '🐼'); +// cardClick('panda2', '🐼'); + + + + +// EVENT LISTENERS FOR ALL OF THE CARDS + +// EVENT LISTENER - DOG 1 +document.getElementById('dog1').addEventListener('click', function() { + + console.log("Dog 1 click works") + + // Detect the current face of the card + // let currentFace = document.getElementById('dog1').getAttribute('value') + const value = document.getElementById('dog1') + console.log(value) + + currentFace = value.innerText; // Removed .textContent + console.log(currentFace) + + if (currentFace === '🐶') { + // document.getElementById('dog1').innerText = ' ' //dogCard1[1] + value.innerText = ''; // Reset if matched + flippedCards.push(value); // Track flipped card + + } else { + // document.getElementById('dog1').innerText = '🐶' //dogCard1[0] + value.innerText = '🐶'; // Show the card + flippedCards.push(value); // Track flipped card + + } + + if (flippedCards.length === 2) { + matchCondition(); + } + + // How do I account for the card being the first and/or second card selected AND how many times it was clicked? (1 time= shown, 2 times = hidden) + + // If this function is clicked switch between 2 boolean values: binary values (><) + + // If this card is the first click fill the first parameter in a function, if not (it's the second click) then run the matchCondition() + + // let dogCard1 = ['🐶', null] + + // if (e === true) { + // console.log("If statement works") + // // Storing the clicked area in a variable and populating it with a dog emoji + // click = e.target + + // click.innerText = "Dog" + + // matchConditions(click, clickTwo) + // } + + // Show dog +}) + +// EVENT LISTENER - DOG 2 +document.getElementById('dog2').addEventListener('click', function() { + + console.log("Dog 2 click works") + // Detect the current face of the card + // let currentFace = document.getElementById('dog1').getAttribute('value') + const value = document.getElementById('dog2') + console.log(value) + + currentFace = value.innerText; + console.log(currentFace) + + if (currentFace === '🐶') { + // document.getElementById('dog2').innerText = ' ' //dogCard1[1] + value.innerText = ''; + flippedCards.push(value); + // matchCondition() + // return + } else { + // document.getElementById('dog2').innerText = '🐶' //dogCard1[0] + value.innerText = '🐶'; + flippedCards.push(value); + // matchCondition() + // return + } + + if (flippedCards.length === 2) { + matchCondition(); + } +}) + +// EVENT LISTENER - RABBIT 1 +document.getElementById('rabbit1').addEventListener('click', function() { + + console.log("Rabbit 1 click works") + // Detect the current face of the card + // let currentFace = document.getElementById('dog1').getAttribute('value') + const value = document.getElementById('rabbit1') + console.log(value) + + currentFace = value.innerText; + console.log(currentFace) + + if (currentFace === '🐰') { + value.innerText = ''; + flippedCards.push(value); + // document.getElementById('rabbit1').innerText = ' ' //dogCard1[1] + // matchCondition() + // return + } else if (currentFace !== '🐰') { + value.innerText = '🐰'; // Show the card + flippedCards.push(value); + // document.getElementById('rabbit1').innerText = '🐰' //dogCard1[0] + // matchCondition() + // return + } else { + return "AHHH" + } + + if (flippedCards.length === 2) { + matchCondition(); + } +}) + +// EVENT LISTENER - RABBIT 2 +document.getElementById('rabbit2').addEventListener('click', function() { + + console.log("Rabbit 2 click works") + // Detect the current face of the card + // let currentFace = document.getElementById('dog1').getAttribute('value') + const value = document.getElementById('rabbit2') + console.log(value) + + currentFace = value.innerText; + console.log(currentFace) + + if (currentFace === '🐰') { + value.innerText = ''; + flippedCards.push(value); + // document.getElementById('rabbit2').innerText = ' ' //dogCard1[1] + // matchCondition() + // return + } else if (currentFace !== '🐰') { + value.innerText = '🐰'; // Reset if matched + flippedCards.push(value); + // document.getElementById('rabbit2').innerText = '🐰' //dogCard1[0] + // matchCondition() + // return + } else { + return "AHHH" + } + + if (flippedCards.length === 2) { + matchCondition(); + } +}) + +// EVENT LISTENER - FOX 1 +document.getElementById('fox1').addEventListener('click', function() { + + console.log("Fox 1 click works") + // Detect the current face of the card + // let currentFace = document.getElementById('dog1').getAttribute('value') + const value = document.getElementById('fox1') + console.log(value) + + currentFace = value.innerText; + console.log(currentFace) + + if (currentFace === '🦊') { + value.innerText = ''; // Reset if matched + flippedCards.push(value); + // document.getElementById('fox1').innerText = ' ' //dogCard1[1] + // matchCondition() + // return + } else if (currentFace !== '🦊') { + value.innerText = '🦊'; // Reset if matched + flippedCards.push(value); + // document.getElementById('fox1').innerText = '🦊' //dogCard1[0] + // matchCondition() + // return + } else { + return "AHHH" + } + + if (flippedCards.length === 2) { + matchCondition(); + } +}) + +// EVENT LISTENER - FOX 2 +document.getElementById('fox2').addEventListener('click', function() { + + console.log("Fox 2 click works") + // Detect the current face of the card + // let currentFace = document.getElementById('dog1').getAttribute('value') + const value = document.getElementById('fox2') + console.log(value) + + currentFace = value.innerText; + console.log(currentFace) + + if (currentFace === '🦊') { + value.innerText = ''; // Reset if matched + flippedCards.push(value); + // document.getElementById('fox2').innerText = ' ' //dogCard1[1] + // matchCondition() + // return + } else if (currentFace !== '🦊') { + value.innerText = '🦊'; // Reset if matched + flippedCards.push(value); + // document.getElementById('fox2').innerText = '🦊' //dogCard1[0] + // matchCondition() + // return + } else { + return "AHHH" + } + + if (flippedCards.length === 2) { + matchCondition(); + } +}) + +// EVENT LISTENER - FROG 1 +document.getElementById('frog1').addEventListener('click', function() { + + console.log("Frog 1 click works") + // Detect the current face of the card + // let currentFace = document.getElementById('dog1').getAttribute('value') + const value = document.getElementById('frog1') + console.log(value) + + currentFace = value.innerText; + console.log(currentFace) + + if (currentFace === '🐸') { + value.innerText = ''; // Reset if matched + flippedCards.push(value); + // document.getElementById('frog1').innerText = ' ' //dogCard1[1] + // matchCondition() + // return + } else if (currentFace !== '🐸') { + value.innerText = '🐸'; // Reset if matched + flippedCards.push(value); + // document.getElementById('frog1').innerText = '🐸' //dogCard1[0] + // matchCondition() + // return + } else { + return "AHHH" + } + + if (flippedCards.length === 2) { + matchCondition(); + } +}) + +// EVENT LISTENER - FROG 2 +document.getElementById('frog2').addEventListener('click', function() { + + console.log("Frog 2 click works") + // Detect the current face of the card + // let currentFace = document.getElementById('dog1').getAttribute('value') + const value = document.getElementById('frog2') + console.log(value) + + currentFace = value.innerText; + console.log(currentFace) + + if (currentFace === '🐸') { + value.innerText = ''; // Reset if matched + flippedCards.push(value); + // document.getElementById('frog2').innerText = ' ' //dogCard1[1] + // matchCondition() + // return + } else if (currentFace !== '🐸') { + value.innerText = '🐸'; // Reset if matched + flippedCards.push(value); + // document.getElementById('frog2').innerText = '🐸' //dogCard1[0] + // matchCondition() + // return + } else { + return "AHHH" + } + + if (flippedCards.length === 2) { + matchCondition(); + } +}) + +// EVENT LISTENER - PANDA 1 +document.getElementById('panda1').addEventListener('click', function() { + + console.log("Panda 1 click works") + // Detect the current face of the card + // let currentFace = document.getElementById('dog1').getAttribute('value') + const value = document.getElementById('panda1') + console.log(value) + + currentFace = value.innerText; + console.log(currentFace) + + if (currentFace === '🐼') { + value.innerText = ''; // Reset if matched + flippedCards.push(value); + // document.getElementById('panda1').innerText = ' ' //dogCard1[1] + // matchCondition() + // return + } else if (currentFace !== '🐼') { + value.innerText = '🐼'; // Reset if matched + flippedCards.push(value); + // document.getElementById('panda1').innerText = '🐼' //dogCard1[0] + // matchCondition() + // return + } else { + return "AHHH" + } + + if (flippedCards.length === 2) { + matchCondition(); + } +}) + +// EVENT LISTENER - PANDA 2 +document.getElementById('panda2').addEventListener('click', function() { + + console.log("Panda 2 click works") + // Detect the current face of the card + // let currentFace = document.getElementById('dog1').getAttribute('value') + const value = document.getElementById('panda2') + console.log(value) + + currentFace = value.innerText; + console.log(currentFace) + + if (currentFace === '🐼') { + value.innerText = ''; // Reset if matched + flippedCards.push(value); + // document.getElementById('panda2').innerText = ' ' //dogCard1[1] + // matchCondition() + // return + } else if (currentFace !== '🐼') { + value.innerText = '🐼'; // Reset if matched + flippedCards.push(value); + // document.getElementById('panda2').innerText = '🐼' //dogCard1[0] + // matchCondition() + // return + } else { + return "AHHH" + } + + if (flippedCards.length === 2) { + matchCondition(); + } +}) +