Skip to content

Commit 9246461

Browse files
committed
feat: add check return for validation #31
- items도 깊은 복사를 지원합니다.
1 parent 6fa00e9 commit 9246461

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/models/Cards/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ export class CardCollection {
6464
checkAnswer(id: string, submit: string) {
6565
const [card] = this.cardArr.filter((card) => card.id === id);
6666
const regex = new RegExp(card.answer, 'i');
67-
regex.test(submit) ? this.#correct(id) : this.#wrong(id);
67+
68+
const isCorrect = regex.test(submit);
69+
isCorrect ? this.#correct(id) : this.#wrong(id);
70+
return isCorrect;
6871
}
6972

7073
#correct(id: string) {
@@ -79,6 +82,6 @@ export class CardCollection {
7982
}
8083

8184
get items() {
82-
return this.cardArr;
85+
return structuredClone(this.cardArr);
8386
}
8487
}

0 commit comments

Comments
 (0)