@@ -13,21 +13,21 @@ const addContainer = document.getElementById("add-container");
1313let currentActiveCard = 0 ;
1414const 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
3232function 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
7171nextButton . 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
110110clearButton . 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
0 commit comments