Open brookr opened 9 years ago
Array.prototype.addBookToShelfTwo = function(Book) { this.push(Book); return this; }
Array.prototype.removeBookFromShelf = function(title) { var index = this.indexOf(title); this.splice(index, 1); return this; }
My shelf objects are new Array Objects so i added the methods to the Array prototype
Improvements here look nice.
How about making actual Book objects, rather than just adding them by name/author?
Also, it's best for Library and Shelf methods to be attached to their respective prototypes.
Otherwise, very close to the solution we are looking for!
Good suggestions, I made the changes
Interesting
Rather than free-floating methods, the methods to add/remove a book should be behaviors of the Shelf object.