Skip to content

Commit

Permalink
Hard Issue (JavaScript) fork-commit-merge#300
Browse files Browse the repository at this point in the history
  • Loading branch information
HadassaAvimor committed Aug 26, 2023
1 parent 36bd8da commit 824287f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tasks/javascript/hard/src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,22 @@ class Library {
}

searchBooks(query) {
// TODO: Implement search functionality
return this.books.filter(i =>
Object.keys(i).some(key => String(i[key]).toLowerCase().includes(query.toLowerCase())));
}

filterBooks(criteria) {
// TODO: Implement filter functionality
const filterKeys = Object.keys(criteria);
return this.books.filter(obj => {
return filterKeys.every(key => {
if (!criteria[key].length) {
return true;
}
return criteria[key] === (obj[key]);
});
});


}
}

Expand Down

0 comments on commit 824287f

Please sign in to comment.