Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
71 changes: 71 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -1 +1,72 @@
// write your code here to make the tests pass

var Library = function() {

var books = [];

var addBook = function(book) {

books.push(book);

} //end addBook

var checkOutBook = function(book) {

if (books.includes(book))
book.setAttribute('checkedOut', true);

else
console.log('Book does not exist in the library');

} //end checkOutBook

var returnBook = function(book) {

if (books.includes(book))
book.setAttribute('checkedOut', false);

else
console.log('Book does not exist in the library');

} //end returnBook

return {

books: books,
addBook: addBook,
checkOutBook: checkOutBook,
returnBook: returnBook

};

} //end Library

var Book = function(title, author) {

let attributes = {
checkedOut: false,
title: title,
author: author
}

var getAttribute = function(attribute) {

return attributes[attribute];

} //getBookAttribute

var setAttribute = function(attribute,data) {

if (attributes.hasOwnProperty(attribute))
attributes[attribute] = data;

} //end setBookAttribute

return {

getAttribute,
setAttribute

};

} //end Book