8000 Changed let to const and added some comments. · joshua-hs/javascript-exercises@fb5677e · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fb5677e

Browse files
authored
Changed let to const and added some comments.
I changed the let to a const and added some explanation to how the test is conducted in comments included in the test.
1 parent 312103d commit fb5677e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

repeatString/repeatString.spec.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff 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(/((hey))/g).length).toEqual(number);
2229
});
2330
});

0 commit comments

Comments
 (0)
0