Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function oldBooks(data) {
- let favBook = data[0];
- let i = 1;
- while (data[i] !== "No More Books") {
- let currentBook = data[i];
- if (currentBook === favBook) {
- console.log(`You checked ${i - 1} books and found it.`);
- favBook = true;
- break;
- }
- i++;
- }
- if (favBook !== true) {
- console.log(`The book you search is not here!`);
- console.log(`You checked ${i - 1} books.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement