Skip to content

Instantly share code, notes, and snippets.

@stoneboyindc
Last active December 2, 2022 20:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stoneboyindc/74e11ddf5c42ddca040b6ba2977c1242 to your computer and use it in GitHub Desktop.
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.
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