Created
March 9, 2021 18:28
-
-
Save stoneboyindc/5ccc9f7eb33ed960441201c0c2c0ef70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// should return all of the books taken out by an account with the author embedded | |
function getBooksPossessedByAccount(account, books, authors) { | |
let books_taken = []; | |
books.forEach(book=>{ | |
if (book.borrows.find(item=>item.id === account.id && !item.returned)) { | |
books_taken.push(book); | |
} | |
}) | |
console.log(books_taken); | |
books_taken.forEach(book=>{ | |
let anAuthor = authors.find(person => person.id === book.authorId); | |
book['author'] = anAuthor; | |
}) | |
console.log(books_taken); | |
return books_taken; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment