Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- removeBook(bookName) {
- if(!this.books.some(x => x.bookName == bookName)){
- throw new Error(`The book, you're looking for, is not found.`)
- }
- if (this.books.some(x => x.payed == false)) {
- throw new Error(`{bookName} need to be paid before removing from the collection.`)
- }else{
- this.books=this.books.filter(x => x.bookName != bookName);
- return "{bookName} remove from the collection."
- }
Advertisement
Add Comment
Please, Sign In to add comment