Skip to content

Commit 9708bf2

Browse files
committed
Exercise
1 parent 6f31ff8 commit 9708bf2

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.DS_Store
1+
.DS_Store
2+
**/node_modules

loops/exercises/for-Loop-Exercises.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@
6767

6868
console.log("Even values: " + even.trim());
6969
console.log("Odd values: " + odd.trim());
70+
7071

loops/exercises/while-Loop-Exercises.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,19 @@ console.log("Orbit achieved!!");
5757
console.log("Failed to reach orbit..");
5858

5959
}
60+
function mealAssembly(protein, grains, veggies, beverages, desserts, numMeals) {
61+
let pantry = [protein, grains, veggies, beverages, desserts];
62+
let meals = [];
63+
// meals: array[array[string, ...]]
64+
// [['chicken', ...], ['pork', ...], ...]
65+
/// Part A #2: Write a ``for`` loop inside this function
66+
/// Code your solution for part A #2 below this comment (and above the return statement) ... ///
67+
for(let i = 0; i<numMeals.length; i++){
68+
meals[i] = []; // meals[i] == meal [..., i'th iteration ->[ ], ...]
69+
for(let j = 0; j<pantry.length; j++){
70+
meals[i].push(pantry[j][i]);
71+
}
72+
}
73+
74+
return meals;
75+
}

0 commit comments

Comments
 (0)