@@ -2,11 +2,11 @@ const input = require('readline-sync');
2
2
3
3
// Part A: #1 Populate these arrays
4
4
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' ] ;
10
10
11
11
12
12
function mealAssembly ( protein , grains , veggies , beverages , desserts , numMeals ) {
@@ -15,7 +15,14 @@ function mealAssembly(protein, grains, veggies, beverages, desserts, numMeals) {
15
15
16
16
/// Part A #2: Write a ``for`` loop inside this function
17
17
/// 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
+ }
19
26
20
27
return meals ;
21
28
}
@@ -25,6 +32,9 @@ function askForNumber() {
25
32
numMeals = input . question ( "How many meals would you like to make?" ) ;
26
33
27
34
/// 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
+ }
28
38
29
39
return numMeals ;
30
40
}
@@ -34,6 +44,10 @@ function generatePassword(string1, string2) {
34
44
let code = '' ;
35
45
36
46
/// Code your Bonus Mission Solution here ///
47
+ for ( let i = 0 ; 1 < string1 . length ; i ++ ) {
48
+ code += string1 [ i ] + string2 [ i ] ;
49
+ }
50
+
37
51
38
52
return code ;
39
53
}
@@ -45,8 +59,8 @@ function runProgram() {
45
59
/// Change the final input variable (aka numMeals) here to ensure your solution makes the right number of meals ///
46
60
/// We've started with the number 2 for now. Does your solution still work if you change this value? ///
47
61
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 )
50
64
51
65
52
66
/// TEST PART B HERE ///
@@ -59,10 +73,10 @@ function runProgram() {
59
73
/// TEST PART C HERE ///
60
74
/// UNCOMMENT the remaining commented lines and change the password1 and password2 strings to ensure your code is doing its job ///
61
75
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 ) } ` ) ;
66
80
}
67
81
68
82
module . exports = {
0 commit comments