-
Notifications
You must be signed in to change notification settings - Fork 0
/
lasagna-master.js
71 lines (53 loc) · 1.61 KB
/
lasagna-master.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
// look back again 😢👏🤷♀️
function cookingStatus(time) {
if (time === 0) {
return "Lasagna is done.";
} else if (time > 0) {
return "Not done, please wait.";
} else {
return "You forgot to set the timer.";
}
}
// console.log(cookingStatus(12));
// console.log(cookingStatus());
///---///
// const layers = ["sauce", "noodles", "sauce", "meat", "mozzarella", "noodles"];
function preparationTime(layers, averagePreparationTime = 2) {
return layers.length * averagePreparationTime;
}
// console.log(preparationTime(layers, 3));
// console.log(preparationTime(layers));
///---///
function quantities(layers) {
let noodles = layers.filter((layer) => layer === "noodles").length * 50;
let sauce = layers.filter((layer) => layer === "sauce").length * 0.2;
return { noodles, sauce };
}
// console.log(
// quantities(["sauce", "noodles", "sauce", "meat", "mozzarella", "noodles"])
// );
///---///
// const friendsList = ["noodles", "sauce", "mozzarella", "kampot pepper"];
// const myList = ["noodles", "meat", "sauce", "mozzarella"];
function addSecretIngredient(friendsList, myList) {
const secretIngredient = friendsList[friendsList.length - 1];
myList.push(secretIngredient);
}
// console.log(addSecretIngredient(friendsList, myList));
// console.log(myList);
///---///
// const recipe = {
// noodles: 200,
// sauce: 0.5,
// mozzarella: 1,
// meat: 100
// };
function scaleRecipe(recipe, amount) {
const scaled = {};
for (const key in recipe) {
scaled[key] = (recipe[key] * amount) / 2;
}
return scaled;
}
// console.log(scaleRecipe(recipe, 4));
// console.log(recipe);