Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bookcheck(input) {
- let i = 0;
- let data = input;
- let book = data[i];
- i++;
- let count = Number(data[i]);
- i++;
- while ((book !== data[i]) && ((i-2) <= count)) {
- i++;
- }
- if (book == data[i]) {
- console.log(`You checked ${i-2} books and found it.`);
- }
- else {
- console.log(`The book you search is not here!`);
- console.log(`You checked ${count} books.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement