str (первый аргумент) для num times (второй аргумент). Верните пустую строку, если num не является положительным числом. Не забудьте использовать Read-Search-Ask, если вы застряли. Напишите свой собственный код.
repeatStringNumTimes("*", 3) should return "***".
testString: assert(repeatStringNumTimes("*", 3) === "***");
- text: repeatStringNumTimes("abc", 3) should return "abcabcabc".
testString: assert(repeatStringNumTimes("abc", 3) === "abcabcabc");
- text: repeatStringNumTimes("abc", 4) should return "abcabcabcabc".
testString: assert(repeatStringNumTimes("abc", 4) === "abcabcabcabc");
- text: repeatStringNumTimes("abc", 1) should return "abc".
testString: assert(repeatStringNumTimes("abc", 1) === "abc");
- text: repeatStringNumTimes("*", 8) should return "********".
testString: assert(repeatStringNumTimes("*", 8) === "********");
- text: repeatStringNumTimes("abc", -2) should return "".
testString: assert(repeatStringNumTimes("abc", -2) === "");
- text: The built-in repeat() method should not be used.
testString: assert(!/\.repeat/g.test(code));
- text: repeatStringNumTimes("abc", 0) should return "".
testString: assert(repeatStringNumTimes("abc", 0) === "");
```