Sikau

JavaScript · Day 41 · about 30 min

Project: Recipe finder

Search recipes by ingredient.

What can I cook?

You have potatoes and onions. What can you make? Let's build a recipe finder that searches a list of recipe objects by ingredient.

The data

const recipes = [
  { name: "Aloo tama", minutes: 40, ingredients: ["potato", "bamboo shoot", "beans"] },
  { name: "Aloo paratha", minutes: 30, ingredients: ["flour", "potato", "onion"] },
  { name: "Egg curry", minutes: 25, ingredients: ["egg", "onion", "tomato"] },
];

console.log(recipes[1].ingredients.includes("onion"));

The rest of this lesson

  • Questions to ask the dataexplain
  • Sorting objects safelyexplain
  • Can I cook it?predict
  • Build canCookorder
  • Step 1: find by ingredientwrite code
  • Step 2: what can I cook?challenge
  • Badge quizquiz
  • Unit 7 complete!recap

Continue this lesson free — run real code in your browser

Continue with Google

See all 68 lessons of JavaScript