File tree Expand file tree Collapse file tree 2 files changed +8
-14
lines changed Expand file tree Collapse file tree 2 files changed +8
-14
lines changed Original file line number Diff line number Diff line change 1
- export const titleCaseString = data => {
2
- const x = data . toLowerCase ( ) ;
3
- const pp = x . split ( ' ' ) ;
4
- return pp . map ( word => word . charAt ( 0 ) . toUpperCase ( ) + word . slice ( 1 ) ) . join ( ' ' ) ;
5
- } ;
1
+ export const titleCaseString = data =>
2
+ data
3
+ . toLowerCase ( )
4
+ . split ( ' ' )
5
+ . map ( word => `${ word . charAt ( 0 ) . toUpperCase ( ) } ${ word . slice ( 1 ) } ` )
6
+ . join ( ' ' ) ;
6
7
7
- export const convertStringToArray = ( para , removeSpaces = false ) => {
8
- const arr = [ ...para ] ;
9
- return ( removeSpaces ) ?
10
- arr . filter ( item => item !== ' ' ) : arr ;
11
- } ;
8
+ export const convertStringToArray = ( para , removeSpaces = false ) =>
9
+ removeSpaces ? [ ...para ] . filter ( item => item !== ' ' ) : [ ...para ] ;
12
10
13
11
export const countInstanceInArray = arr => arr . reduce ( ( obj , item ) => {
14
12
if ( ! obj [ item ] ) obj [ item ] = 0 ;
Original file line number Diff line number Diff line change @@ -19,10 +19,6 @@ test('Capitalize First Character after Space', () => (
19
19
expect ( titleCaseString ( 'hello world' ) ) . toBe ( 'Hello World' )
20
20
) ) ;
21
21
22
- test ( 'Capitalize First Character after Space' , ( ) => (
23
- expect ( titleCaseString ( 'hello world' ) ) . toBe ( 'Hello World' )
24
- ) ) ;
25
-
26
22
// String to Array //
27
23
28
24
test ( 'Convert String to Array' , ( ) => (
You can’t perform that action at this time.
0 commit comments