passed returns ERROR with negative numbers
This commit is contained in:
parent
b3038bccd0
commit
6cf3662f55
|
@ -2,6 +2,10 @@ const repeatString = function(sourceString, stringCount) {
|
||||||
//Declare variable/s
|
//Declare variable/s
|
||||||
let resultString = '';
|
let resultString = '';
|
||||||
|
|
||||||
|
//Return error if stringCounter is negative
|
||||||
|
if (stringCount < 0) {
|
||||||
|
return 'ERROR';
|
||||||
|
}
|
||||||
|
|
||||||
// Create a for loop to repeat the string
|
// Create a for loop to repeat the string
|
||||||
for (let i = 0; i < stringCount; i++) {
|
for (let i = 0; i < stringCount; i++) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe('repeatString', function() {
|
||||||
it('repeats the string 0 times', function() {
|
it('repeats the string 0 times', function() {
|
||||||
expect(repeatString('hey', 0)).toEqual('');
|
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');
|
expect(repeatString('hey', -1)).toEqual('ERROR');
|
||||||
});
|
});
|
||||||
xit('repeats the string a random amount of times', function() {
|
xit('repeats the string a random amount of times', function() {
|
||||||
|
|
Loading…
Reference in New Issue