-
-
Save stoneboyindc/74e11ddf5c42ddca040b6ba2977c1242 to your computer and use it in GitHub Desktop.
It should return an array of all the transactions from the book's `borrows` key. However, each transaction should include the related account information and the `returned` key.
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
function getBorrowersForBook(book, accounts) { | |
let result = []; | |
let borrowArray = book.borrows; | |
borrowArray.forEach(borrow=>{ | |
let account = accounts.find(acc => acc.id === borrow.id); | |
let obj = account; | |
obj['returned'] = borrow.returned; | |
result.push(obj); | |
}) | |
console.log(result); | |
return result.slice(0,10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment