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
4 changes: 3 additions & 1 deletion SpecRunner.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner v2.3.4</title>
Expand All @@ -20,4 +21,5 @@

<body>
</body>
</html>

</html>
60 changes: 60 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -1 +1,61 @@
// write your code here to make the tests pass

// Library Module
var Library = function() {
var books = [];

var addBook = function(book) {
books.push(book);
book.setAttribute('checkedOut', false);
};

var returnBook = function(book) {
if (!books.includes(book)) {
return console.log('book is not in the Library');
}

if (book.getAttribute('checkedOut') === true) {
return book.setAttribute('checkedOut', false)
}
};

var checkOutBook = function(book) {
if (books.includes(book)) {
book.setAttribute('checkedOut', true);
}
};

return {
addBook: addBook,
returnBook: returnBook,
checkOutBook: checkOutBook
}

};


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

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

var setAttribute = function(attribute, value) {
if (attributes.hasOwnProperty(attribute)) {
attributes[attribute] = value;
}
};

return {
getAttribute: getAttribute,
setAttribute: setAttribute
};
};