From 546ce67fe851e8360bf8ac396ff655ee5d4fd9df Mon Sep 17 00:00:00 2001 From: David Wu Date: Sat, 23 Dec 2017 15:59:44 +0100 Subject: [PATCH] Update repeatString.md --- snippets/repeatString.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/snippets/repeatString.md b/snippets/repeatString.md index fbccf52d2..619fe767b 100644 --- a/snippets/repeatString.md +++ b/snippets/repeatString.md @@ -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 -const repeatString = (str="",num=1) => { +const repeatString = (str="",num=2) => { return num >= 0 ? str.repeat(num) : str; } -// toRepeatString("abc",3) -> 'abcabcabc' -// toRepeatString("abc",0) -> '' -// toRepeatString("abc") -> 'abc' -// toRepeatString("abc",-1) -> 'abc' -// toRepeatString() -> '' -// toRepeatString(undefined,3) -> '' +// repeatString("abc",3) -> 'abcabcabc' +// repeatString("abc",0) -> '' +// repeatString("abc") -> 'abcabc' ```