Link has a bunch of ingredients and he want’s to experiment and see what kinds of meals he can make with them. He knows for sure that when he cooks Hylian Rice
with a Big Hearty Truffle
that he gets Mushroom Rice Balls
, but for some reason he’s not seeing it in his meals…
On his travels, he found some recipes on the walls of the stables he’s visited:
Hateno Cheese
and aBird Egg
will make aCheesy Omlette
Tabantha Wheat
andHateno Cheese
will make aCheesy Hylian Pizza
Raw Prime Meat
andHylian Rice
will makePrime Meat and Rice Bowl
Open the main.js
module in your code editor and you will see that some code has already been started. Unfortunately, the algorithm is not comprehensive, as if will only cook one meal based off of two ingredients. You need to refactor that algorithm so that it will work for any of the combinations above.
To start you off, we want you to think about the structure of a recipe object - what properties would need to be on it, and what would the value be of each property.
Then update the function so that if two matching ingredients are passed as arguments to the cook()
function, the matching meal name will be produced.
Link found some more materials in the Tabantha Frontier, he also stopped in Rito village to buy a few items. Add the following items to his materials array:
'Goat Butter', 'Fresh Milk', 'Cane Sugar', 'Raw Bird Thigh'
Link has also learned a few new recipes:
Fresh Milk
,Cane Sugar
, and aBird Egg
will makeEgg Pudding
Tabantha Wheat
,Cane Sugar
,Goat Butter
, and aBird Egg
will make anEgg Tart
Hylian Rice
,Raw Prime Meat
, and aBird Egg
will makeChicken Egg Fried Rice
Hylian Rice
,Goat Butter
, aBird Egg
and aRaw Bird Thigh
will makePoultry Pilaf
Notice how these recipes require more than one ingredient. Some require three, some require four, and the previous recipes still only require two. Discuss with your team how you can update the existing function. You may need to practice your googling skills 😉
- What should the parameter(s) for the cook function be to account for any number of ingredients?
- How do we pass in the specific ingredients to the function?
- How can we check for the specific ingredients?