File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 1
- var palindromes = function ( ) {
2
-
1
+ var palindromes = function ( text ) {
2
+ const regex = new RegExp ( / [ ! , \. \s ] / , 'g' ) ;
3
+ const strippedText = text . toLowerCase ( ) . replace ( regex , "" ) ;
4
+ const reversedText = strippedText . split ( "" ) . reverse ( ) . join ( "" ) ;
5
+ return reversedText === strippedText ? true : false ;
3
6
}
4
7
5
8
module . exports = palindromes
Original file line number Diff line number Diff line change @@ -4,16 +4,16 @@ describe('palindromes', function() {
4
4
it ( 'works with single words' , function ( ) {
5
5
expect ( palindromes ( 'racecar' ) ) . toEqual ( true ) ;
6
6
} ) ;
7
- xit ( 'works with punctuation' , function ( ) {
7
+ it ( 'works with punctuation' , function ( ) {
8
8
expect ( palindromes ( 'Racecar!' ) ) . toEqual ( true ) ;
9
9
} ) ;
10
- xit ( 'works with multiple words' , function ( ) {
10
+ it ( 'works with multiple words' , function ( ) {
11
11
expect ( palindromes ( 'A car, a man, a maraca.' ) ) . toEqual ( true ) ;
12
12
} ) ;
13
- xit ( 'works with multiple words' , function ( ) {
13
+ it ( 'works with multiple words' , function ( ) {
14
14
expect ( palindromes ( 'Animal loots foliated detail of stool lamina.' ) ) . toEqual ( true ) ;
15
15
} ) ;
16
- xit ( 'doesn\'t just always return true' , function ( ) {
16
+ it ( 'doesn\'t just always return true' , function ( ) {
17
17
expect ( palindromes ( 'ZZZZ car, a man, a maraca.' ) ) . toEqual ( false ) ;
18
18
} ) ;
19
19
You can’t perform that action at this time.
0 commit comments