Skip to content

solved #1955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

solved #1955

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions src/memory.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
class MemoryGame {
constructor(cards) {
this.cards = cards;
// add the rest of the class properties here
this.pickedCards = [];
this.pairsClicked = 0;
this.pairsGuessed = 0;
}

shuffleCards() {
// ... write your code here
if (!this.cards)
return undefined;
const newCards = [...this.cards];
this.cards.sort(() => Math.random() - 0.7);
return this.cards;
}

checkIfPair(card1, card2) {
// ... write your code here
this.pairsClicked++;
if (card1 === card2) {
this.pairsGuessed++;
return true;
} else {
return false;
}
}

checkIfFinished() {
// ... write your code here
return this.pairsGuessed === this.cards.length / 2
}
}
}