Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function maxima(input) {
- //Input
- let favBook = input.shift();
- let libraryCapacity = Number(input.shift());
- let i = 0;
- //Code
- while (i <= libraryCapacity) {
- let bookChecker = input.shift();
- if (bookChecker === favBook) {
- console.log(`You checked ${i} books and found it.`);
- break;
- } else if (i === libraryCapacity) {
- console.log("The book you search is not here!");
- console.log(`You checked ${i} books.`);
- }
- i++;
- }
- }
Add Comment
Please, Sign In to add comment