commit
efde1e3846
|
@ -1,8 +1,12 @@
|
|||
const repeatString = function(word, times) {
|
||||
let arr = word.split(' ');
|
||||
|
||||
for (let i = 1; i < times; i++) {
|
||||
arr.push(word);
|
||||
let arr = [];
|
||||
|
||||
if (times < 0) {
|
||||
return 'ERROR';
|
||||
} else {
|
||||
for (let i = 0; i < times; i++) {
|
||||
arr.push(word);
|
||||
}
|
||||
}
|
||||
|
||||
return arr.join('');
|
||||
|
|
|
@ -9,7 +9,7 @@ describe('repeatString', function() {
|
|||
expect(repeatString('hey', 10)).toEqual('heyheyheyheyheyheyheyheyheyhey');
|
||||
});
|
||||
|
||||
it('repeats the string 1 times', function() {
|
||||
it('repeats the string 1 time', function() {
|
||||
expect(repeatString('hey', 1)).toEqual('hey');
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue