num
times(第二个参数)重复给定的字符串str
(第一个参数)。如果num
不是正数,则返回空字符串。如果卡住,请记得使用Read-Search-Ask 。编写自己的代码。 repeatStringNumTimes("*", 3)
应该返回"***"
。'
testString: 'assert(repeatStringNumTimes("*", 3) === "***", "repeatStringNumTimes("*", 3)
should return "***"
.");'
- text: 'repeatStringNumTimes("abc", 3)
应该返回"abcabcabc"
。'
testString: 'assert(repeatStringNumTimes("abc", 3) === "abcabcabc", "repeatStringNumTimes("abc", 3)
should return "abcabcabc"
.");'
- text: 'repeatStringNumTimes("abc", 4)
应返回"abcabcabcabc"
。'
testString: 'assert(repeatStringNumTimes("abc", 4) === "abcabcabcabc", "repeatStringNumTimes("abc", 4)
should return "abcabcabcabc"
.");'
- text: 'repeatStringNumTimes("abc", 1)
应该返回"abc"
。'
testString: 'assert(repeatStringNumTimes("abc", 1) === "abc", "repeatStringNumTimes("abc", 1)
should return "abc"
.");'
- text: 'repeatStringNumTimes("*", 8)
应该返回"********"
。'
testString: 'assert(repeatStringNumTimes("*", 8) === "********", "repeatStringNumTimes("*", 8)
should return "********"
.");'
- text: 'repeatStringNumTimes("abc", -2)
应返回""
。'
testString: 'assert(repeatStringNumTimes("abc", -2) === "", "repeatStringNumTimes("abc", -2)
should return ""
.");'
- text: 不应使用内置的repeat()
方法
testString: 'assert(!/\.repeat/g.test(code), "The built-in repeat()
-method should not be used");'
```