我有这本书的捐赠系统,它具有以下课程(Book,Donor) 我直接创建了对象
这些是我创建的一些对象。
应用
let Book1 = {
bookId : 112233,
title : "HarryPotter",
author: "J. K. Rowling",
imageUrl :"image",
donor : "Daniel Radcliffe",
status : "Available",
}
let Book2 = {
bookId : 112233,
title : "Jane Eyre",
author: "Charlotte Brontë",
imageUrl :"image",
donor : "Mia Wasikowska ",
status : "Pending ",
}
let Donor1 = {
donorId : 2244,
firstname : "Daniel",
lastname : "Radcliffe",
phoneNumber : 99088988,
street : "Platform 9¾",
city : "London",
email : "R@hotmail.com",
password : "123",
}
book.addBook(Book1);
book.updateBook()
book.getDonorBooks(2244)
BookCatalog
class BookCatalog {
constructor(){
this.books = [];
}
addBook(book) {
this.books.push(book)
}
updateBook(){
return this.books.reduce(pre , curr) =>{
if(pre.bookId == curr.bookId )
curr.bookId = 1111
}
}
getDonorBooks(doonrId){
}
}
module.exports = BookCatalog ;
updateBook()应该将书籍作为输入,并更新具有匹配bookId的书籍。
getDonorBooks()应该获取donorId,并返回特定捐赠者捐赠的所有书籍。
我不知道如何执行这两种方法。