MCPcopy Create free account
hub / github.com/appacademy/Module-1-Resources / iceCreamShop

Function iceCreamShop

w3/d2/eod.js:56–66  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

54***********************************************************************/
55
56function 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected