Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function library(input) {
- let index = 1
- let neededBook = input[0]
- let book = 0
- let checkedBooks = 0
- while (book !== "No More Books") {
- book = input[index]
- if (book == neededBook) {
- console.log(`You checked ${index-2} books and found it.`);
- break;
- }
- checkedBooks++
- index++
- }
- console.log(`The book you search is not here!`);
- console.log(`You checked ${index-2} books.`);
- }
- library (["Bourne",
- "True Story",
- "Forever",
- "More Space",
- "The Girl",
- "Spaceship",
- "Strongest",
- "Profit",
- "Tripple",
- "Stella",
- "The Matrix",
- "Bourne"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement