10
10
// 6. Optional: Use method chaining to reduce the lines of code within the function.
11
11
12
12
function reverseCharacters ( str ) {
13
- return str . split ( "" ) . reverse ( ) . join ( "" ) ;
14
- }
13
+ return str . split ( "" ) . reverse ( ) . join ( "" ) ;
14
+ }
15
15
16
16
let word = "apple" ;
17
17
18
18
console . log ( reverseCharacters ( word ) ) ;
19
19
20
-
21
20
// Part Two: Reverse Digits
22
21
23
22
// 1. Add an if statement to reverseCharacters to check the typeof the parameter.
@@ -47,9 +46,9 @@ console.log(reverseCharacters2(num));
47
46
// 5. Return the final, reversed array.
48
47
// 6. Be sure to print the results from each test case in order to verify your code.
49
48
50
- let arrayTest1 = [ ' apple' , ' potato' , ' Capitalized Words' ] ;
49
+ let arrayTest1 = [ " apple" , " potato" , " Capitalized Words" ] ;
51
50
let arrayTest2 = [ 123 , 8897 , 42 , 1168 , 8675309 ] ;
52
- let arrayTest3 = [ ' hello' , ' world' , 123 , ' orange' ] ;
51
+ let arrayTest3 = [ " hello" , " world" , 123 , " orange" ] ;
53
52
54
53
function reverseArray ( arr ) {
55
54
return arr . reverse ( ) . map ( ( e ) => {
@@ -59,7 +58,6 @@ function reverseArray(arr) {
59
58
60
59
console . log ( reverseArray ( arrayTest3 ) ) ;
61
60
62
-
63
61
// Bonus Missions
64
62
65
63
// 1. Have a clear, descriptive name like funPhrase.
0 commit comments