Update repeatString.md

This commit is contained in:
David Wu
2017-12-23 15:59:44 +01:00
committed by GitHub
parent 7bce20a457
commit 401fd73dc6

View File

@ -1,17 +1,14 @@
### toKebabCase ### repeatString
Repeats a string n times using String.repeat() Repeats a string n times using `String.repeat()`
If no string is provided the default is `""` and the default number of times is 1 If no string is provided the default is `""` and the default number of times is 2.
```js ```js
const repeatString = (str="",num=1) => { const repeatString = (str="",num=2) => {
return num >= 0 ? str.repeat(num) : str; return num >= 0 ? str.repeat(num) : str;
} }
// toRepeatString("abc",3) -> 'abcabcabc' // repeatString("abc",3) -> 'abcabcabc'
// toRepeatString("abc",0) -> '' // repeatString("abc",0) -> ''
// toRepeatString("abc") -> 'abc' // repeatString("abc") -> 'abcabc'
// toRepeatString("abc",-1) -> 'abc'
// toRepeatString() -> ''
// toRepeatString(undefined,3) -> ''
``` ```