Write a recursive function `iceCreamShop(flavors, favorite)` that takes in an array of ice cream flavors available at the ice cream shop, as well as the user's favorite ice cream flavor. Recursively find out whether or not the shop offers their favorite flavor.
(flavors, favorite)
| 54 | ***********************************************************************/ |
| 55 | |
| 56 | function iceCreamShop(flavors, favorite){ |
| 57 | |
| 58 | if (!flavors.length) return false; |
| 59 | |
| 60 | // let flavor = flavors.pop(); |
| 61 | |
| 62 | if (flavors.pop() === favorite) return true; |
| 63 | |
| 64 | return iceCreamShop(flavors, favorite) |
| 65 | |
| 66 | } |
| 67 | |
| 68 | |
| 69 | // console.log(iceCreamShop(['vanilla', 'strawberry'], 'blue moon')); // false |
nothing calls this directly
no outgoing calls
no test coverage detected