From 9ab82c675d7f3e1e54e993d2623e915d8cd08888 Mon Sep 17 00:00:00 2001 From: borobor Date: Tue, 15 Feb 2022 21:28:08 +0100 Subject: [PATCH] Write a function that passes first 4 tests --- 02_repeatString/repeatString.js | 8 ++++++-- 02_repeatString/repeatString.spec.js | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/02_repeatString/repeatString.js b/02_repeatString/repeatString.js index 4359bbe..7a76d3a 100644 --- a/02_repeatString/repeatString.js +++ b/02_repeatString/repeatString.js @@ -1,5 +1,9 @@ -const repeatString = function() { - +const repeatString = function(word, num) { + let out = ''; + for (i = 0; i < num; i++) { + out += word; + } + return out; }; // Do not edit below this line diff --git a/02_repeatString/repeatString.spec.js b/02_repeatString/repeatString.spec.js index 912ac20..4761d72 100644 --- a/02_repeatString/repeatString.spec.js +++ b/02_repeatString/repeatString.spec.js @@ -4,13 +4,13 @@ describe('repeatString', () => { test('repeats the string', () => { expect(repeatString('hey', 3)).toEqual('heyheyhey'); }); - test.skip('repeats the string many times', () => { + test('repeats the string many times', () => { expect(repeatString('hey', 10)).toEqual('heyheyheyheyheyheyheyheyheyhey'); }); - test.skip('repeats the string 1 times', () => { + test('repeats the string 1 times', () => { expect(repeatString('hey', 1)).toEqual('hey'); }); - test.skip('repeats the string 0 times', () => { + test('repeats the string 0 times', () => { expect(repeatString('hey', 0)).toEqual(''); }); test.skip('returns ERROR with negative numbers', () => {