@@ -2,17 +2,27 @@ 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 ) {
13
13
let pantry = [ protein , grains , veggies , beverages , desserts ] ;
14
14
let meals = [ ] ;
15
-
15
+ for ( let i = 0 ; i < numMeals ; i ++ ) {
16
+
17
+ let meal = [ ] ;
18
+
19
+ for ( let m = 0 ; m < pantry . length ; m ++ ) {
20
+ meal . push ( pantry [ m ] [ i ] ) ;
21
+
22
+ }
23
+ meals . push ( meal )
24
+ }
25
+
16
26
/// Part A #2: Write a ``for`` loop inside this function
17
27
/// Code your solution for part A #2 below this comment (and above the return statement) ... ///
18
28
@@ -23,15 +33,26 @@ function mealAssembly(protein, grains, veggies, beverages, desserts, numMeals) {
23
33
24
34
function askForNumber ( ) {
25
35
numMeals = input . question ( "How many meals would you like to make?" ) ;
26
-
27
36
/// CODE YOUR SOLUTION TO PART B here ///
37
+ while ( numMeals < 0 || numMeals > 6 )
38
+ numMeals = input . question ( " Please enter a number between 1 & 6." ) ;
28
39
29
40
return numMeals ;
30
41
}
31
42
32
43
44
+
33
45
function generatePassword ( string1 , string2 ) {
34
46
let code = '' ;
47
+ string1 = "12345" ;
48
+ string2 = "67890" ;
49
+ string1 . split ( "" ) ;
50
+ string2 . split ( "" ) ;
51
+ let codeArray = [ ]
52
+ for ( i = 0 ; i < string1 . length ; i ++ ) {
53
+ codeArray . push ( string1 [ i ] , string2 [ i ] ) ;
54
+ }
55
+ code = codeArray . join ( "" ) ;
35
56
36
57
/// Code your Bonus Mission Solution here ///
37
58
@@ -45,24 +66,24 @@ function runProgram() {
45
66
/// Change the final input variable (aka numMeals) here to ensure your solution makes the right number of meals ///
46
67
/// We've started with the number 2 for now. Does your solution still work if you change this value? ///
47
68
48
- // let meals = mealAssembly(protein, grains, veggies, beverages, desserts, 2 );
49
- // console.log(meals)
69
+ let meals = mealAssembly ( protein , grains , veggies , beverages , desserts , 6 ) ;
70
+ console . log ( meals )
50
71
51
72
52
73
/// TEST PART B HERE ///
53
74
/// UNCOMMENT the next two lines to test your ``askForNumber`` solution ///
54
75
/// Tip - don't test this part until you're happy with your solution to part A #2 ///
55
76
56
- // let mealsForX = mealAssembly(protein, grains, veggies, beverages, desserts, askForNumber());
57
- // console.log(mealsForX);
77
+ let mealsForX = mealAssembly ( protein , grains , veggies , beverages , desserts , askForNumber ( ) ) ;
78
+ console . log ( mealsForX ) ;
58
79
59
80
/// TEST PART C HERE ///
60
81
/// UNCOMMENT the remaining commented lines and change the password1 and password2 strings to ensure your code is doing its job ///
61
82
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)}`);
83
+ let password1 = '' ;
84
+ let password2 = '' ;
85
+ console . log ( "Time to run the password generator so we can update the menu tomorrow." )
86
+ console . log ( `The new password is: ${ generatePassword ( password1 , password2 ) } ` ) ;
66
87
}
67
88
68
89
module . exports = {
0 commit comments