Skip to content

Commit d8cbe3f

Browse files
author
Edward King
committed
Worked with group thru code
1 parent 8fd920e commit d8cbe3f

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

loops/studio/solution.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ const input = require('readline-sync');
22

33
// Part A: #1 Populate these arrays
44

5-
let protein = [];
6-
let grains = [];
7-
let veggies = [];
8-
let beverages = [];
9-
let desserts = [];
5+
let protein = ['chicken', 'pork', 'tofu', 'beef', 'fish', 'beans'];
6+
let grains = ['rice', 'pasta', 'corn', 'potato', 'quinoa', 'crackers'];
7+
let veggies = ['peas', 'green beans', 'kale', 'edamame', 'broccoli', 'asparagus'];
8+
let beverages = ['juice', 'milk', 'water', 'soy milk', 'soda', 'tea'] ;
9+
let desserts = ['apple', 'banana', 'more kale', 'ice cream', 'chocolate', 'kiwi'];
1010

1111

1212
function mealAssembly(protein, grains, veggies, beverages, desserts, numMeals) {
@@ -16,8 +16,16 @@ function mealAssembly(protein, grains, veggies, beverages, desserts, numMeals) {
1616
/// Part A #2: Write a ``for`` loop inside this function
1717
/// Code your solution for part A #2 below this comment (and above the return statement) ... ///
1818

19+
for (let i = 0; i < protein.length; i++){
20+
for (let j = i; j < protein.length; j++){
21+
meals.push(pantry[j][i]);
1922

23+
}
24+
25+
}
2026
return meals;
27+
28+
2129
}
2230

2331

@@ -45,8 +53,8 @@ function runProgram() {
4553
/// Change the final input variable (aka numMeals) here to ensure your solution makes the right number of meals ///
4654
/// We've started with the number 2 for now. Does your solution still work if you change this value? ///
4755

48-
// let meals = mealAssembly(protein, grains, veggies, beverages, desserts, 2);
49-
// console.log(meals)
56+
let meals = mealAssembly(protein, grains, veggies, beverages, desserts, 2);
57+
console.log(meals)
5058

5159

5260
/// TEST PART B HERE ///

0 commit comments

Comments
 (0)