-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecipe-tracker.js
More file actions
58 lines (46 loc) · 1.51 KB
/
Copy pathrecipe-tracker.js
File metadata and controls
58 lines (46 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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);
function getTotalIngredients(ingredients) {
return ingredients.length;
}
function getDifficultyLevel(cookingTime) {
if (cookingTime <= 30) {
return "easy";
} else if (cookingTime <= 60) {
return "medium";
} else {
return "hard";
}
}
const recipe1TotalIngredients = getTotalIngredients(recipe1.ingredients);
console.log(recipe1TotalIngredients);
const recipe1DifficultyLevel = getDifficultyLevel(recipe1.cookingTime);
console.log(recipe1DifficultyLevel);
recipe1.totalIngredients = getTotalIngredients(recipe1.ingredients);
recipe1.difficultyLevel = getDifficultyLevel(recipe1.cookingTime);
recipe2.totalIngredients = getTotalIngredients(recipe2.ingredients);
recipe2.difficultyLevel = getDifficultyLevel(recipe2.cookingTime);
recipe3.totalIngredients = getTotalIngredients(recipe3.ingredients);
recipe3.difficultyLevel = getDifficultyLevel(recipe3.cookingTime);
console.log(recipes)