Skip to content

Commit b1cabfb

Browse files
still working
1 parent 129764f commit b1cabfb

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

loops/studio/solution.js

Lines changed: 26 additions & 12 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) {
@@ -15,7 +15,14 @@ function mealAssembly(protein, grains, veggies, beverages, desserts, numMeals) {
1515

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) ... ///
18-
18+
for (let i = 0; i < numMeals; i++) {
19+
let meal = [];
20+
21+
for (let j = 0; j < pantry.length; j++) {
22+
meal.push(pantry[j][i])
23+
}
24+
meals.push(meal)
25+
}
1926

2027
return meals;
2128
}
@@ -25,6 +32,9 @@ function askForNumber() {
2532
numMeals = input.question("How many meals would you like to make?");
2633

2734
/// CODE YOUR SOLUTION TO PART B here ///
35+
while (numMeals < 1 || numMeals > 6 || isNaN(numMeals)) {
36+
numMeals = input.question("I can only make 1-6 meals. How many would you like? ");
37+
}
2838

2939
return numMeals;
3040
}
@@ -34,6 +44,10 @@ function generatePassword(string1, string2) {
3444
let code = '';
3545

3646
/// Code your Bonus Mission Solution here ///
47+
for (let i = 0; 1 < string1.length; i++) {
48+
code+= string1[i] + string2[i];
49+
}
50+
3751

3852
return code;
3953
}
@@ -45,8 +59,8 @@ function runProgram() {
4559
/// Change the final input variable (aka numMeals) here to ensure your solution makes the right number of meals ///
4660
/// We've started with the number 2 for now. Does your solution still work if you change this value? ///
4761

48-
// let meals = mealAssembly(protein, grains, veggies, beverages, desserts, 2);
49-
// console.log(meals)
62+
let meals = mealAssembly(protein, grains, veggies, beverages, desserts, 2);
63+
console.log(meals)
5064

5165

5266
/// TEST PART B HERE ///
@@ -59,10 +73,10 @@ function runProgram() {
5973
/// TEST PART C HERE ///
6074
/// UNCOMMENT the remaining commented lines and change the password1 and password2 strings to ensure your code is doing its job ///
6175

62-
// let password1 = '';
63-
// let password2 = '';
64-
// console.log("Time to run the password generator so we can update the menu tomorrow.")
65-
// console.log(`The new password is: ${generatePassword(password1, password2)}`);
76+
let password1 = 'LoOt';
77+
let password2 = 'oku!';
78+
console.log("Time to run the password generator so we can update the menu tomorrow.")
79+
console.log(`The new password is: ${generatePassword(password1, password2)}`);
6680
}
6781

6882
module.exports = {

0 commit comments

Comments
 (0)