File tree Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Original file line number Diff line number Diff line change 1
- const reverseString = function ( ) {
1
+ const reverseString = function ( string ) {
2
+ let result = "" ;
3
+ for ( let i = string . length - 1 ; i >= 0 ; i -- ) {
4
+ result += string [ i ] ;
5
+ }
6
+ return result ;
7
+ } ;
2
8
3
- }
4
-
5
- module . exports = reverseString
9
+ module . exports = reverseString ;
Original file line number Diff line number Diff line change 1
- const reverseString = require ( ' ./reverseString' )
1
+ const reverseString = require ( " ./reverseString" ) ;
2
2
3
- describe ( ' reverseString' , function ( ) {
4
- it ( ' reverses single word' , function ( ) {
5
- expect ( reverseString ( ' hello' ) ) . toEqual ( ' olleh' ) ;
3
+ describe ( " reverseString" , function ( ) {
4
+ it ( " reverses single word" , function ( ) {
5
+ expect ( reverseString ( " hello" ) ) . toEqual ( " olleh" ) ;
6
6
} ) ;
7
7
8
- xit ( ' reverses multiple words' , function ( ) {
9
- expect ( reverseString ( ' hello there' ) ) . toEqual ( ' ereht olleh' )
10
- } )
8
+ it ( " reverses multiple words" , function ( ) {
9
+ expect ( reverseString ( " hello there" ) ) . toEqual ( " ereht olleh" ) ;
10
+ } ) ;
11
11
12
- xit ( ' works with
5930
numbers and punctuation' , function ( ) {
13
- expect ( reverseString ( ' 123! abc!' ) ) . toEqual ( ' !cba !321' )
14
- } )
12
+ it ( " works with numbers and punctuation" , function ( ) {
13
+ expect ( reverseString ( " 123! abc!" ) ) . toEqual ( " !cba !321" ) ;
14
+ } ) ;
15
15
} ) ;
You can’t perform that action at this time.
0 commit comments