Write a function that passes first 4 tests

This commit is contained in:
borobor 2022-02-15 21:28:08 +01:00
parent fba1f69f65
commit 9ab82c675d
2 changed files with 9 additions and 5 deletions

View File

@ -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

View File

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