|
1 | 1 | 'use strict' |
| 2 | +// this solution we took it in the session on Sunday because it does not make any sence to loop throgh only one object |
| 3 | + |
| 4 | + |
| 5 | +/* |
| 6 | +const pizzaRecipe = {}; |
| 7 | +pizzaRecipe.title = 'Pizza'; |
| 8 | +pizzaRecipe.servings = 1; |
| 9 | +pizzaRecipe.ingredients = ['Flower', 'Tomato Sauce', 'Mushroom', 'Mozzarella']; |
| 10 | +
|
| 11 | +const falafelRecipe = {}; |
| 12 | +falafelRecipe.title = 'Falafel'; |
| 13 | +falafelRecipe.servings = 8; |
| 14 | +falafelRecipe.ingredients = ['Chickpeas', 'Tahine', 'Spices']; |
| 15 | +
|
| 16 | +const recipes = [ |
| 17 | + pizzaRecipe, |
| 18 | + falafelRecipe |
| 19 | + ]; |
| 20 | +
|
| 21 | +recipes.forEach(recipe => { |
| 22 | + console.log('Meal Name :',recipe.title); |
| 23 | + console.log('Servings :', recipe.servings); |
| 24 | + const ingredientString = recipe.ingredients.join(", "); |
| 25 | + console.log('Ingredients :', ingredientString); |
| 26 | + }) |
| 27 | + */ |
| 28 | + |
| 29 | +// this way to solve the exercise is also discused in the sunday session |
| 30 | + |
| 31 | + |
| 32 | +const myMeal = {}; |
| 33 | +myMeal.title = 'sapghetti with bashamel suce'; |
| 34 | +myMeal.servings = 2; |
| 35 | +myMeal.ingredientString = ['spaghetti', 'Mashroum', 'bahsamel souce']; |
| 36 | +console.log("meal title: "+ myMeal.title); |
| 37 | +console.log("meal servings: " + myMeal.servings); |
| 38 | +console.log("ingredient:" + myMeal.ingredientString.join(', ')); |
| 39 | + |
| 40 | + |
| 41 | +/*acctually I dont understand why do we need to use a loop for this exercise if this way is not good |
| 42 | +pleas inform me so I can update it */ |
0 commit comments