File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,14 @@ describe('repeatString', function() {
1717 expect ( repeatString ( 'hey' , - 1 ) ) . toEqual ( 'ERROR' ) ;
1818 } ) ;
1919 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. */
2128 expect ( repeatString ( 'hey' , number ) . match ( / ( ( h e y ) ) / g) . length ) . toEqual ( number ) ;
2229 } ) ;
2330} ) ;
You can’t perform that action at this time.
0 commit comments