Skip to content

Commit 0c221e8

Browse files
author
Edward King
committed
Part 2 Complete
1 parent 8e33b91 commit 0c221e8

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

arrays/exercises/part-one-arrays.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//Create an array called practiceFile with the following entry: 273.15
2-
let practiceFile = [273.15];
2+
let practiceFile = ["273.15"];
33
//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 change
4-
practiceFile[1] = 42;
4+
practiceFile[1] = "42";
55

66
practiceFile[2] = "hello";
77
//console.log(practiceFile);
88
//Use a single .push() to add the following items: false, -4.6, and "87". Print the array to confirm the changes.
9-
practiceFile.push(false, -4.6,"87");
9+
practiceFile.push("false", "-4.6","87");
1010
console.log(practiceFile);

arrays/exercises/part-two-arrays.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
let cargoHold = ['oxygen tanks', 'space suits', 'parrot', 'instruction manual', 'meal packs', 'slinky', 'security blanket'];
22

33
//1) Use bracket notation to replace ‘slinky’ with ‘space tether’. Print the array to confirm the change.
4-
4+
cargoHold[5] = "space tether";
5+
console.log(cargoHold);
56
//2) Remove the last item from the array with pop. Print the element removed and the updated array.
6-
7+
cargoHold.pop();
8+
console.log(cargoHold);
79
//3) Remove the first item from the array with shift. Print the element removed and the updated array.
8-
10+
//console.log(cargoHold.shift());
11+
//console.log(cargoHold);
912
//4) Unlike pop and shift, push and unshift require arguments inside the (). Add the items 1138 and ‘20 meters’ to the the array - the number at the start and the string at the end. Print the updated array to confirm the changes.
10-
13+
cargoHold.push("20 meters");
14+
cargoHold.unshift(1138);
15+
console.log(cargoHold);
1116
//5) Use a template literal to print the final array and its length.
17+
console.log(`${cargoHold} = ${cargoHold.length} items`);

0 commit comments

Comments
 (0)