curriculum/challenges/english/blocks/workshop-recipe-tracker/66fbcf750a62784cf11f5632.md
Create a getTotalIngredients function that takes a single argument, representing an array with ingredients, and returns the number of ingredients from the array passed to the function.
You should create a getTotalIngredients function.
assert.isFunction(getTotalIngredients);
Your getTotalIngredients function should have a single parameter.
assert.lengthOf(getTotalIngredients, 1);
Your getTotalIngredients function should return a number.
assert.isNumber(getTotalIngredients(recipe1.ingredients));
getTotalIngredients(recipe1.ingredients) should return 4.
assert.strictEqual(getTotalIngredients(recipe1.ingredients), 4);
getTotalIngredients(recipe2.ingredients) should return 5.
assert.strictEqual(getTotalIngredients(recipe2.ingredients), 5);
getTotalIngredients(recipe3.ingredients) should return 3.
assert.strictEqual(getTotalIngredients(recipe3.ingredients), 3);
const recipes = [];
const recipe1 = {
name: "Spaghetti Carbonara",
ingredients: ["spaghetti", "Parmesan cheese", "pancetta", "black pepper"],
cookingTime: 22,
totalIngredients: null,
difficultyLevel: ""
};
const recipe2 = {
name: "Chicken Curry",
ingredients: ["chicken breast", "coconut milk", "curry powder", "onion", "garlic"],
cookingTime: 42,
totalIngredients: null,
difficultyLevel: ""
};
const recipe3 = {
name: "Vegetable Stir Fry",
ingredients: ["broccoli", "carrot", "bell pepper"],
cookingTime: 15,
totalIngredients: null,
difficultyLevel: ""
};
recipes.push(recipe1, recipe2, recipe3);
--fcc-editable-region--
--fcc-editable-region--