Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function oldBooks(input) {
- let book = input[0];
- let bookCount = Number(input[1]);
- let counter = 0, index = 2;
- let command = input[index++];
- for (let i = 0; i < bookCount && command != ""; i++) {
- if (command == "No More Books" || command == book) {
- if (command == book) {
- console.log(`You checked ${counter} books and found it.`);
- } else {
- console.log(`The book you search is not here!\nYou checked ${counter} books.`);
- }
- return;
- }
- command = input[index++];
- counter++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement