Advertisement
DraconiusNX

Untitled

Oct 12th, 2022
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. function oldBooks(data) {
  2. let favBook = data[0];
  3. let i = 1;
  4. while (data[i] !== "No More Books") {
  5. let currentBook = data[i];
  6. if (currentBook === favBook) {
  7. console.log(`You checked ${i - 1} books and found it.`);
  8. favBook = true;
  9. break;
  10. }
  11. i++;
  12. }
  13. if (favBook !== true) {
  14. console.log(`The book you search is not here!`);
  15. console.log(`You checked ${i - 1} books.`);
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement