8000 Merge pull request #73 from Timework/patch-1 · codekacode/javascript-exercises@c0d736a · GitHub
[go: up one dir, main page]

Skip to content

Commit c0d736a

Browse files
authored
Merge pull request TheOdinProject#73 from Timework/patch-1
2 parents 26d610c + fb5677e commit c0d736a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

repeatString/repeatString.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,15 @@ describe('repeatString', function() {
1616
xit('returns ERROR with negative numbers', function() {
1717
expect(repeatString('hey', -1)).toEqual('ERROR');
1818
});
19+
xit('repeats the string a random amount of times', function () {
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. */
28+
expect(repeatString('hey', number).match(/((hey))/g).length).toEqual(number);
29+
});
1930
});

0 commit comments

Comments
 (0)
0