Skip to content

Commit 22be97e

Browse files
committed
fix memory cards
1 parent 63b8f8b commit 22be97e

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

72-memory cards/script.js

+27-26
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ const addContainer = document.getElementById("add-container");
1313
let currentActiveCard = 0;
1414
const cardsElement = [];
1515

16-
// const cardsData = [
17-
// {
18-
// question: "What does CSS stand for?",
19-
// answer: "Cascading Style Sheets",
20-
// },
21-
// {
22-
// question: "What year was JavaScript launched?",
23-
// answer: "1995",
24-
// },
25-
// {
26-
// question: "What does HTML stand for?",
27-
// answer: "Hypertext Markup Language",
28-
// },
29-
// ];
30-
const cardsData = getCardsData();
16+
const cardsData = [
17+
{
18+
question: "What does CSS stand for?",
19+
answer: "Cascading Style Sheets",
20+
},
21+
{
22+
question: "What year was JavaScript launched?",
23+
answer: "1995",
24+
},
25+
{
26+
question: "What does HTML stand for?",
27+
answer: "Hypertext Markup Language",
28+
},
29+
];
30+
// const cardsData = getCardsData();
3131

3232
function createCards() {
3333
cardsData.forEach((data, index) => createCard(data, index));
@@ -57,15 +57,15 @@ function updateCurrentText() {
5757
currentElement.innerText = `${currentActiveCard + 1}/${cardsElement.length}`;
5858
}
5959

60-
function getCardsData() {
61-
const cards = JSON.parse(localStorage.getItem("cards"));
62-
return cards === null ? [] : cards;
63-
}
60+
// function getCardsData() {
61+
// const cards = JSON.parse(localStorage.getItem("cards"));
62+
// return cards === null ? [] : cards;
63+
// }
6464

65-
function setCardsData(cards) {
66-
localStorage.setItem("cards", JSON.stringify(cards));
67-
history.go(0);
68-
}
65+
// function setCardsData(cards) {
66+
// localStorage.setItem("cards", JSON.stringify(cards));
67+
// history.go(0);
68+
// }
6969

7070
// Event Listeners
7171
nextButton.addEventListener("click", () => {
@@ -103,14 +103,15 @@ addCardButton.addEventListener("click", () => {
103103
answerElement.value = "";
104104
addContainer.classList.remove("show");
105105
cardsData.push(newCard);
106-
setCardsData(cardsData);
106+
// setCardsData(cardsData);
107107
}
108108
});
109109

110110
clearButton.addEventListener("click", () => {
111-
localStorage.clear();
111+
// localStorage.clear();
112112
cardsContainer.innerHTML = "";
113-
history.go(0);
113+
currentElement.innerText = "";
114+
// history.go(0);
114115
});
115116

116117
// Init

72-memory cards/style.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ h1 button {
5353

5454
.btn-margin {
5555
margin-top: 1.25rem;
56-
width: 90%;
56+
width: 28.125rem;
57+
max-width: 90%;
5758
}
5859

5960
.btn:hover {

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
| 69 | [Infinite Scroll Posts](https://github.com/solygambas/html-css-fifty-projects/tree/master/69-infinite%20scroll%20posts) | [Live Demo](https://codepen.io/solygambas/full/qBqvyEB) |
7878
| 70 | [Typing Game](https://github.com/solygambas/html-css-fifty-projects/tree/master/70-typing%20game) | [Live Demo](https://codepen.io/solygambas/full/wvoOQvq) |
7979
| 71 | [Speech Text Reader](https://github.com/solygambas/html-css-fifty-projects/tree/master/71-speech%20text%20reader) | [Live Demo](https://codepen.io/solygambas/full/QWGPLVM) |
80-
| 72 | [Memory Cards](https://github.com/solygambas/html-css-fifty-projects/tree/master/72-memory%20cards) | [Live Demo](#) |
80+
| 72 | [Memory Cards](https://github.com/solygambas/html-css-fifty-projects/tree/master/72-memory%20cards) | [Live Demo](https://codepen.io/solygambas/full/oNYOqjv) |
8181
| 73 | [Lyrics Search App](https://github.com/solygambas/html-css-fifty-projects/tree/master/73-lyrics%20search%20app) | [Live Demo](#) |
8282
| 74 | [Relaxer App](https://github.com/solygambas/html-css-fifty-projects/tree/master/74-relaxer%20app) | [Live Demo](#) |
8383
| 75 | [Breakout Game](https://github.com/solygambas/html-css-fifty-projects/tree/master/75-breakout%20game) | [Live Demo](#) |

0 commit comments

Comments
 (0)