diff --git a/repeatString/repeatString.js b/repeatString/repeatString.js index 62df807..b66ff26 100644 --- a/repeatString/repeatString.js +++ b/repeatString/repeatString.js @@ -2,6 +2,10 @@ const repeatString = function(sourceString, stringCount) { //Declare variable/s let resultString = ''; + //Return error if stringCounter is negative + if (stringCount < 0) { + return 'ERROR'; + } // Create a for loop to repeat the string for (let i = 0; i < stringCount; i++) { diff --git a/repeatString/repeatString.spec.js b/repeatString/repeatString.spec.js index 20bff3f..d7fa59b 100644 --- a/repeatString/repeatString.spec.js +++ b/repeatString/repeatString.spec.js @@ -13,7 +13,7 @@ describe('repeatString', function() { it('repeats the string 0 times', function() { expect(repeatString('hey', 0)).toEqual(''); }); - xit('returns ERROR with negative numbers', function() { + it('returns ERROR with negative numbers', function() { expect(repeatString('hey', -1)).toEqual('ERROR'); }); xit('repeats the string a random amount of times', function() {