Btwonu

Untitled

Mar 14th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function maxima(input) {
  2. //Input
  3.     let favBook = input.shift();
  4.     let libraryCapacity = Number(input.shift());
  5.     let i = 0;
  6.    
  7. //Code
  8.     while (i <= libraryCapacity) {
  9.  
  10.         let bookChecker = input.shift();
  11.  
  12.         if (bookChecker === favBook) {
  13.             console.log(`You checked ${i} books and found it.`);
  14.             break;
  15.         } else if (i === libraryCapacity) {
  16.             console.log("The book you search is not here!");
  17.             console.log(`You checked ${i} books.`);
  18.         }
  19.         i++;
  20.     }
  21. }
Add Comment
Please, Sign In to add comment