Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import * as data from './book-data.js'
- const books = data.books;
- const genre = data.bookGenre;
- const pagesInRange = (books).sort((a, b) => a.pages - b.pages);
- // I want to map the books to have genere name instead of id, after that I need to return only the books that return a specified genere.
- const booksByGenre = (books, findThisGenre) => {
- let bookArr = books.map((book) => {
- for (const key in genre) {
- console.log(genre[key] === book.genre)
- if (genre[key] === book.genre) {
- console.log(book.genre, key)
- book.genre = key;
- console.log(book);
- }
- }
- })
- console.log(bookArr);
- return bookArr.some((el) => {
- el.genre === findThisGenre;
- })
- };
- const check = booksByGenre;
- console.log(check(books, 'Sci-Fi'));
Advertisement
Add Comment
Please, Sign In to add comment