diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/main.js b/main.js index 220d2e1..f39cd2b 100644 --- a/main.js +++ b/main.js @@ -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 \ No newline at end of file