Skip to content
Open
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
53 changes: 52 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
@@ -1 +1,52 @@
// write your code here to make the tests pass
var Library = function() {
var books = [];

var addBook = function(book) {
books.push(book);
};

var checkOutBook = function(book) {
if (books.includes(book)) {
book.setAttribute("checkedOut", true);
} else {
console.log("We don't stock that book.");
}
};

var returnBook = function(book) {
if (books.includes(book)) {
book.setAttribute("checkedOut", false);
} else {
console.log("We don't stock that book.");
}
};

return {
addBook,
checkOutBook,
returnBook,
};
};

var Book = function(title, author) {
var attributes = {
title,
author,
checkedOut: false,
};

var getAttribute = function(attribute) {
return attributes[attribute];
};

var setAttribute = function(attribute, attributeInfo) {
if (attribute in attributes) {
attributes[attribute] = attributeInfo;
}
};

return {
getAttribute,
setAttribute,
};
};