Skip to content

Commit 2abb7b5

Browse files
committed
revised exercises
1 parent 6a563a9 commit 2abb7b5

File tree

6 files changed

+15
-6
lines changed

6 files changed

+15
-6
lines changed

arrays/exercises/part-five-arrays.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
let str = 'In space, no one can hear you code.';
22
let arr = ['B', 'n', 'n', 5];
3+
console.log(str);
4+
console.log(arr);
5+
console.log('------');
36

47
//1) Use the split method on the string to identify the purpose of the parameter inside the ().
58
console.log(str.split());
69
console.log(str.split('e'));
710
console.log(str.split(' '));
811
console.log(str.split(''));
12+
console.log('------');
913

1014
//2) Use the join method on the array to identify the purpose of the parameter inside the ().
1115
console.log(arr.join());
1216
console.log(arr.join('a'));
1317
console.log(arr.join(' '));
1418
console.log(arr.join(''));
19+
console.log('------');
1520

1621
//3) Do split or join change the original string/array?
17-
console.log('no');
22+
console.log('No, but they are printed as alterations of the string/array.');
23+
console.log('------');
1824

1925
//4) We can take a comma-separated string and convert it into a modifiable array. Try it! Alphabetize the cargoHold string, and then combine the contents into a new string.
2026
let cargoHold = "water,space suits,food,plasma sword,batteries";

arrays/exercises/part-four-arrays.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
let holdCabinet1 = ['duct tape', 'gum', 3.14, false, 6.022e23];
22
let holdCabinet2 = ['orange drink', 'nerf toys', 'camera', 42, 'parsnip'];
3+
console.log(holdCabinet1);
4+
console.log(holdCabinet2);
35

46
//Explore the methods concat, slice, reverse, and sort to determine which ones alter the original array.
57

arrays/exercises/part-one-arrays.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
//Create an array called practiceFile with the following entry: 273.15
22
let practiceFile = [273.15];
3-
4-
//Use the bracket notation method to add "42" and "hello" to the array. Add these new items one at a time. Print the array after each step to confirm the changes.
53
console.log(practiceFile);
64

5+
//Use the bracket notation method to add "42" and "hello" to the array. Add these new items one at a time. Print the array after each step to confirm the changes.
76
practiceFile.push(42);
87
console.log(practiceFile);
98

arrays/exercises/part-six-arrays.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ let element26 = ['iron', 'Fe', 55.85];
99
let table = [];
1010
table.push(element1, element2, element26);
1111
console.log(table);
12+
1213
//3) Use bracket notation to examine the difference between printing 'table' with one index vs. two indices (table[][]).
1314
console.log(table[1]);
14-
console.log(table[1][1]);
15+
console.log(table[0][1]);
1516

1617
//4) Using bracket notation and the table array, print the mass of element1, the name for element 2 and the symbol for element26.
1718
console.log(table[0][2]);
@@ -20,7 +21,7 @@ console.log(table[2][1]);
2021

2122
//5) 'table' is an example of a 2-dimensional array. The first “level” contains the element arrays, and the second level holds the name/symbol/mass values. Experiment! Create a 3-dimensional array and print out one entry from each level in the array.
2223

23-
/* I have no idea how to create the third level. Does it split off of an item in another level?
24+
// /* I have no idea how to create the third level. Does it split off of an item in another level?
2425
let num1 = [1, 2, 3];
2526
let color1 = ['red', 'blue'];
2627
let nothingSpecial1 = ['earth', true, 7];

arrays/exercises/part-three-arrays.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
let cargoHold = [1138, 'space suits', 'parrot', 'instruction manual', 'meal packs', 'space tether', '20 meters'];
2+
console.log(cargoHold);
23

34
//Use splice to make the following changes to the cargoHold array. Be sure to print the array after each step to confirm your updates.
45

arrays/exercises/part-two-arrays.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
let cargoHold = ['oxygen tanks', 'space suits', 'parrot', 'instruction manual', 'meal packs', 'slinky', 'security blanket'];
2+
console.log(cargoHold);
23

34
//1) Use bracket notation to replace ‘slinky’ with ‘space tether’. Print the array to confirm the change.
45
cargoHold[5] = 'space tether';
@@ -18,5 +19,4 @@ cargoHold.unshift(1138);
1819
console.log(cargoHold);
1920

2021
//5) Use a template literal to print the final array and its length.
21-
console.log(cargoHold.length);
2222
console.log(`${cargoHold}, (${cargoHold.length})`)

0 commit comments

Comments
 (0)