Skip to content

Commit 229e539

Browse files
authored
fix(curriculum): add validation test for filteredBooks release year (freeCodeCamp#64228)
1 parent cb6669f commit 229e539

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

curriculum/challenges/english/blocks/lab-book-organizer/67172b43f84bcd2dec238a3d.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,28 @@ assert.isBelow(filteredBooks.length, books.length)
8989
assert.isNotEmpty(filteredBooks)
9090
```
9191

92+
The `filteredBooks` array should only contain books from the original `books` array.
93+
94+
```js
95+
filteredBooks.forEach(book => {
96+
assert.isTrue(
97+
books.some(original =>
98+
original.title === book.title &&
99+
original.authorName === book.authorName &&
100+
original.releaseYear === book.releaseYear
101+
)
102+
);
103+
});
104+
```
105+
106+
The `filteredBooks` array should include only books released on or before a specified year.
107+
108+
```js
109+
const maxYear = Math.max(...filteredBooks.map(book => book.releaseYear));
110+
const removedYears = books.filter(book => !filteredBooks.includes(book)).map(book => book.releaseYear);
111+
assert.isTrue(removedYears.every(year => year > maxYear));
112+
```
113+
92114
You should call the `sort` higher order function by passing the `sortByYear` callback function on the `filteredBooks` array.
93115

94116
```js

0 commit comments

Comments
 (0)