Advertisement
Liliana797979

viarno reshenie old books

Feb 12th, 2021
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function book(input) {
  2.     let favouriteBook = input[0];
  3.     let index = 1;
  4.     let bookIsFound = false;
  5.  
  6.     let bookNextName = input[index];
  7.     while (bookNextName !== "No More Books") {
  8.         if (bookNextName === favouriteBook) {
  9.             bookIsFound = true;
  10.             break;
  11.         }
  12.         index++;
  13.         bookNextName = input[index];
  14.     }
  15.     if (bookIsFound === false) {
  16.         console.log(`The book you search is not here!`);
  17.         console.log(`You checked ${index - 1} books.`);
  18.     } else {
  19.         console.log(`You checked ${index - 1} books and found it.`);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement