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