neZnam121

Untitled

Feb 19th, 2022
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1.  removeBook(bookName) {
  2.         if(!this.books.some(x => x.bookName == bookName)){
  3.             throw new Error(`The book, you're looking for, is not found.`)
  4.        }
  5.        if (this.books.some(x => x.payed == false)) {
  6.            throw new Error(`{bookName} need to be paid before removing from the collection.`)
  7.        }else{
  8.            this.books=this.books.filter(x => x.bookName != bookName);
  9.            return "{bookName} remove from the collection."
  10.        }
Advertisement
Add Comment
Please, Sign In to add comment