Skip to content

Commit 5db6d93

Browse files
committed
part 5
1 parent 7a30fba commit 5db6d93

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

arrays/exercises/part-five-arrays.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,24 @@ let str = 'In space, no one can hear you code.';
22
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 ().
5+
console.log(str.split());
6+
console.log(str.split('e'));
7+
console.log(str.split(' '));
8+
console.log(str.split(''));
9+
510

611
//2) Use the join method on the array to identify the purpose of the parameter inside the ().
12+
console.log(arr.join());
13+
console.log(arr.join('a'));
14+
console.log(arr.join(' '));
15+
console.log(arr.join(''));
716

17+
console.log(arr);
818
//3) Do split or join change the original string/array?
919

10-
//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.
20+
//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
21+
//into a new string.
22+
23+
1124
let cargoHold = "water,space suits,food,plasma sword,batteries";
25+
console.log(cargoHold.split(",").sort().join(','));

0 commit comments

Comments
 (0)