JSFiddle - React, Tailwind, and code Playground
by lavisha99
JavaScript
function books(ID, title, name, genres, borrowers) {
this.ID = ID;
this.name = name;
this.title = title;
this.genres = genres;
this.borrowers = [];
}
//#3.2 Create a constructor for member objects. A library member has:
// ID, name, email, and contact phone.
function libraryMem(ID, name, email, contact) {
this.ID = ID;
this.name = name;
this.email = email;
this.contact = contact;
}
let member01 = new Member (14, 'Kate', '[email protected]', 02103485177);
let member02 = new Member (9, 'Sam', '[email protected]', 02153372856);
let member03 = new Member (48, 'Iris', '[email protected]', 02216112846);
/*
/*
#3.3 Create a constructor for creating a library object.
- The library has a name and address
- A list of books which is a collection of book objects.
- A list of members which is a list of member objects
*/
function libraryObj(name, address, booksObj, MembersObj) {
this.name = name;
this.address = address;
this.membersObj = MembersObj;
this.booksObj = [];
this.addBook = function(thisBook) {
this.booksObj.push(thisBook);
}
this.borrowbook = function(bookId, memberId){
}
}
let book1 = new books(1, '1title', ['romance', 'comedy'], ['lavisha']);
let book2 = new books(2, '2title', ['romance', 'comedy'], ['lavisha']);
let book3 = new books(3, '3title', ['romance', 'comedy'], ['lavisha']);
let book4 = new books(4, '4title', ['romance', 'comedy'], ['lavisha']);
let book5 = new books(5, '5title', ['romance', 'comedy'], ['lavisha']);
let booksArray = [book1, book2, book3, book4, book5]
let newbook = ['bookA']
let newmember = new libraryMem(23, 'A', '[email protected]', 12345);
let newLibObject = new libraryObj('sonu', 'K road');
newLibObject.addBook(newbook);
newLibObject.addBook(book1);
newLibObject.addBook(book2);
newLibObject.addBook(book3);
newLibObject.addBook(book4);
newLibObject.addBook(book5);
//newLibObj.addBook(booksArray);
console.log(newLibObject);
/*#3.6 Add a "borrowBook" function to the library constructor...