Skip to content

Commit 59f6932

Browse files
committed
part 5 done
1 parent 114fdb3 commit 59f6932

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

arrays/exercises/part-five-arrays.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@ let arr = ['B', 'n', 'n', 5];
33

44
//1) Use the split method on the string to identify the purpose of the parameter inside the ().
55

6+
console.log(str.split("o"));
7+
//split will split a string into an array at the the character specified in the ("") and also delete those characters, if ("") is empty like this, it will split between every character.
8+
69
//2) Use the join method on the array to identify the purpose of the parameter inside the ().
710

11+
console.log(arr.join("n"));
12+
//join does the opposite of split and concotanates a array into a string adding the character in the () in between the gaps like glue.
13+
814
//3) Do split or join change the original string/array?
915

16+
//no
17+
1018
//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.
1119
let cargoHold = "water,space suits,food,plasma sword,batteries";
20+
cargoHold = cargoHold.split(',').sort().join(',');
21+
console.log(cargoHold);

0 commit comments

Comments
 (0)