passed returns ERROR with negative numbers

This commit is contained in:
Mohammed Nabeel 2020-07-02 09:41:16 +03:00
parent b3038bccd0
commit 6cf3662f55
2 changed files with 5 additions and 1 deletions

View File

@ -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++) {

View File

@ -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() {