Skip to content

Commit b1b3a4e

Browse files
June LeeJune Lee
authored andcommitted
multi-array studio
1 parent 7eef208 commit b1b3a4e

14 files changed

Lines changed: 178 additions & 131 deletions

arrays/studio/multi-dimensional-arrays.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,23 @@ let pets = "parrots,cats,moose,alien eggs";
44
let sleepAids = "blankets,pillows,eyepatches,alarm clocks";
55

66
//1) Use split to convert the strings into four cabinet arrays. Alphabetize the contents of each cabinet.
7-
7+
food = food.split(",").sort();
8+
console.log(food);
9+
equipment = equipment.split(",").sort();
10+
pets = pets.split(",").sort();
11+
sleepAids = sleepAids.split(",").sort();
812
//2) Initialize a cargoHold array and add the cabinet arrays to it. Print cargoHold to verify its structure.
9-
13+
cargoHold = [food, equipment, pets, sleepAids];
14+
console.log(cargoHold);
1015
//3) Query the user to select a cabinet (0 - 3) in the cargoHold.
11-
16+
const input = require('readline-sync');
17+
let info =input.question("select a cabinet (0-3)");
1218
//4) Use bracket notation and a template literal to display the contents of the selected cabinet. If the user entered an invalid number, print an error message.
13-
19+
console.log(`You have chosen Cabinet ${info}! Here are the contents: ${cargoHold[info]}`);
1420
//5) Modify the code to query the user for BOTH a cabinet in cargoHold AND a particular item. Use the 'includes' method to check if the cabinet contains the selected item, then print “Cabinet ____ DOES/DOES NOT contain ____.”
21+
let info2 = input.question("select item: ");
22+
if (cargoHold[info].includes(info2.toLowerCase())) {
23+
console.log(`Cabinet ${info} DOES contain ${info2.toLowerCase()}`)
24+
} else {
25+
console.log(`Cabinet ${info} DOES NOT contain ${info2.toLowerCase()}`)
26+
}

arrays/studio/node_modules/.package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

arrays/studio/node_modules/readline-sync/LICENSE

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

arrays/studio/node_modules/readline-sync/LICENSE-MIT

Lines changed: 0 additions & 22 deletions
This file was deleted.

arrays/studio/node_modules/readline-sync/README.md

Lines changed: 17 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

arrays/studio/node_modules/readline-sync/lib/encrypt.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

arrays/studio/node_modules/readline-sync/lib/read.cs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

arrays/studio/node_modules/readline-sync/lib/read.ps1

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

arrays/studio/node_modules/readline-sync/lib/read.sh

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)