Advertisement
zarkoto223

oldBooks

Feb 24th, 2024
672
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function asd(input){
  2. let book=input[0]
  3. let index=1
  4. let found=false
  5. let bookFav=input[index]
  6.  
  7. while(bookFav!=='No More Books'){
  8.     if(bookFav===book){
  9.         found=true
  10.         break
  11.     }
  12.     index++
  13.     bookFav=input[index]
  14. }
  15. if(found===false){
  16.     console.log(`The book you search is not here!`)
  17. console.log(`You checked ${index-1} books.`)
  18.  
  19. }else{
  20.     console.log(`You checked ${index-1} books and found it.`)
  21. }
  22.  
  23.  
  24. }
  25. asd(["The Spot",
  26. "Hunger Games",
  27. "Harry Potter",
  28. "Torronto",
  29. "Spotify",
  30. "No More Books"])
  31.  
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement