Skip to content

Instantly share code, notes, and snippets.

@commanderh
Created February 23, 2021 02:49
Show Gist options
  • Save commanderh/091ff030c4053104570169a0527a7940 to your computer and use it in GitHub Desktop.
Save commanderh/091ff030c4053104570169a0527a7940 to your computer and use it in GitHub Desktop.
/***********************************************************************
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.
Examples:
iceCreamShop(['vanilla', 'strawberry'], 'blue moon'); // false
iceCreamShop(['pistachio', 'green tea', 'chocolate', 'mint chip'], 'green tea'); // true
iceCreamShop(['cookies n cream', 'blue moon', 'superman', 'honey lavender', 'sea salt caramel'], 'pistachio'); // false
iceCreamShop(['moose tracks'], 'moose tracks'); // true
iceCreamShop([], 'honey lavender'); // false
***********************************************************************/
// your code here
/**************DO NOT MODIFY ANYTHING UNDER THIS LINE*****************/
try {
module.exports = iceCreamShop;
} catch (e) {
module.exports = null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment