File tree 1 file changed +8
-1
lines changed 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,14 @@ describe('repeatString', function() {
17
17
expect ( repeatString ( 'hey' , - 1 ) ) . toEqual ( 'ERROR' ) ;
18
18
} ) ;
19
19
xit ( 'repeats the string a random amount of times' , function ( ) {
20
- let number = Math . floor ( Math . random ( ) * 1000 )
20
+ /*The number is generated by using Math.random to get a value from between
21
+ 0 to 1, when this is multiplied by 1000 and rounded down with Math.floor it
22
+ equals a number between 0 to 999 (this number will change everytime you run
23
+ the test).*/
24
+ const number = Math . floor ( Math . random ( ) * 1000 )
25
+ /*The .match(/((hey))/g).length is a regex that will count the number of heys
26
+ in the result, which if your function works correctly will equal the number that
27
+ was randomaly generated. */
21
28
expect ( repeatString ( 'hey' , number ) . match ( / ( ( h e y ) ) / g) . length ) . toEqual ( number ) ;
22
29
} ) ;
23
30
} ) ;
You can’t perform that action at this time.
0 commit comments