Advertisement
Btwonu

index

Mar 14th, 2020
149
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[0];
  4.     let libraryCapacity = input[1];
  5.     let i = 2;
  6.    
  7. //Code
  8.     while (i <= input.length) {
  9.         let bookChecker = input[i];
  10.         if (bookChecker === favBook) {
  11.             console.log(`You checked ${i - 2} books and found it.`);
  12.             break;
  13.         } else if (bookChecker === undefined) {
  14.             console.log("The book you search is not here!");
  15.             console.log(`You checked ${i - 2} books.`);
  16.         }
  17.         i++;
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement