@@ -4,32 +4,29 @@ let protoArray3 = "space delimited string";
4
4
let protoArray4 = "Comma-spaces, might, require, typing, caution" ;
5
5
6
6
strings = [ protoArray1 , protoArray2 , protoArray3 , protoArray4 ] ;
7
- console . log ( protoArray1 . includes ( " " ) ) ;
7
+
8
8
//2)
9
9
function reverseCommas ( ) {
10
10
//TODO: 1. create and instantiate your variables.
11
- // let check;
11
+ let check ;
12
12
let output = protoArray1 . split ( "," ) . reverse ( ) . join ( "," ) ;
13
13
//TODO: 2. write the code required for this step
14
-
15
14
//NOTE: For the code to run properly, you must return your output. this needs to be the final line of code within the function's { }.
16
15
return output ;
17
16
}
18
17
19
18
//3)
20
19
function semiDash ( ) {
21
20
let check ;
22
- let output ;
21
+ let output = protoArray2 . split ( ";" ) . sort ( ) . join ( "-" ) ;
23
22
//TODO: write the code required for this step
24
-
25
-
26
23
return output ;
27
24
}
28
25
29
26
//4)
30
27
function reverseSpaces ( ) {
31
28
let check ;
32
- let output ;
29
+ let output = protoArray3 . split ( " " ) . sort ( ) . reverse ( ) . join ( " " ) ;
33
30
//TODO: write the code required for this step
34
31
35
32
return output ;
@@ -38,7 +35,7 @@ function reverseSpaces() {
38
35
//5)
39
36
function commaSpace ( ) {
40
37
let check ;
41
- let output ;
38
+ let output = protoArray4 . split ( ", " ) . reverse ( ) . join ( ", " ) ;
42
39
//TODO: write the code required for this step
43
40
44
41
return output ;
@@ -51,4 +48,4 @@ module.exports = {
51
48
semiDash : semiDash ,
52
49
reverseSpaces : reverseSpaces ,
53
50
commaSpace : commaSpace
54
- } ;
51
+ } ;
0 commit comments