diff --git a/frontend/files/app.js b/frontend/files/app.js index 2a53e87..78e598a 100644 --- a/frontend/files/app.js +++ b/frontend/files/app.js @@ -100,10 +100,11 @@ function apiResponseParsing(book) { function search(books, searchBy, includeChildrensBooks) { searchBy = searchCleaner(searchBy); - if (searchBy !== "") { - books = books.filter( - ({ title, authors, genre, publisher, series, year, childrens }) => { - var inSearch = Object.values({ + books = books.filter( + ({ title, authors, genre, publisher, series, year, childrens }) => { + var inSearch = true; + if (searchBy !== "") { + inSearch = Object.values({ title, authors: authors.join(" "), genre, @@ -111,13 +112,13 @@ function search(books, searchBy, includeChildrensBooks) { series, year, }).find((field) => searchCleaner(field).indexOf(searchBy) !== -1); - if (!includeChildrensBooks) { - return inSearch && !childrens; - } - return inSearch; } - ); - } + if (!includeChildrensBooks) { + return inSearch && !childrens; + } + return inSearch; + } + ); return books; }