diff --git a/02_repeatString/repeatString.spec.js b/02_repeatString/repeatString.spec.js index b075f33..07d226f 100644 --- a/02_repeatString/repeatString.spec.js +++ b/02_repeatString/repeatString.spec.js @@ -26,11 +26,8 @@ describe('repeatString', () => { this test generates a random number, then passes it into your code with a function parameter. If this doesn't make sense, you should go read about functions here: https://www.theodinproject.com/paths/foundations/courses/foundations/lessons/fundamentals-part-3 */ - const number = Math.floor(Math.random() * 1000) - /*The .match(/((hey))/g).length is a regex that will count the number of heys - in the result, which if your function works correctly will equal the number that - was randomly generated. */ - expect(repeatString('hey', number).match(/((hey))/g).length).toEqual(number); + const number = Math.floor(Math.random() * 1000); + expect(repeatString('hey', number)).toBe('hey'.repeat(number)); }); test.skip('works with blank strings', () => { expect(repeatString('', 10)).toEqual(''); diff --git a/02_repeatString/solution/repeatString-solution.spec.js b/02_repeatString/solution/repeatString-solution.spec.js index 74c3d6f..4d68047 100644 --- a/02_repeatString/solution/repeatString-solution.spec.js +++ b/02_repeatString/solution/repeatString-solution.spec.js @@ -27,12 +27,7 @@ describe('repeatString', () => { If this doesn't make sense, you should go read about functions here: https://www.theodinproject.com/paths/foundations/courses/foundations/lessons/fundamentals-part-3 */ const number = Math.floor(Math.random() * 1000); - /*The .match(/((hey))/g).length is a regex that will count the number of heys - in the result, which if your function works correctly will equal the number that - was randomly generated. */ - expect(repeatString('hey', number).match(/((hey))/g).length).toEqual( - number - ); + expect(repeatString('hey', number)).toBe('hey'.repeat(number)); }); test('works with blank strings', () => { expect(repeatString('', 10)).toEqual('');