diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string.english.md
index 47a2dece88..14a967bea9 100644
--- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string.english.md
+++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string.english.md
@@ -22,20 +22,22 @@ Remember to use should return "***"
.
- testString: assert(repeatStringNumTimes("*", 3) === "***", 'repeatStringNumTimes("*", 3)
should return "***"
.');
+ testString: assert(repeatStringNumTimes("*", 3) === "***");
- text: repeatStringNumTimes("abc", 3)
should return "abcabcabc"
.
- testString: assert(repeatStringNumTimes("abc", 3) === "abcabcabc", '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", '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", 'repeatStringNumTimes("abc", 1)
should return "abc"
.');
+ testString: assert(repeatStringNumTimes("abc", 1) === "abc");
- text: repeatStringNumTimes("*", 8)
should return "********"
.
- testString: assert(repeatStringNumTimes("*", 8) === "********", 'repeatStringNumTimes("*", 8)
should return "********"
.');
+ testString: assert(repeatStringNumTimes("*", 8) === "********");
- text: repeatStringNumTimes("abc", -2)
should return ""
.
- testString: assert(repeatStringNumTimes("abc", -2) === "", 'repeatStringNumTimes("abc", -2)
should return ""
.');
- - text: The built-in repeat()
-method should not be used
- testString: assert(!/\.repeat/g.test(code), 'The built-in repeat()
-method should not be used');
-
+ 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) === "");
+
```
@@ -66,7 +68,7 @@ repeatStringNumTimes("abc", 3);
```js
function repeatStringNumTimes(str, num) {
- if (num < 0) return '';
+ if (num < 1) return '';
return num === 1 ? str : str + repeatStringNumTimes(str, num-1);
}
diff --git a/guide/english/certifications/javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string/index.md b/guide/english/certifications/javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string/index.md
index e621cdc223..06776d0b9a 100644
--- a/guide/english/certifications/javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string/index.md
+++ b/guide/english/certifications/javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string/index.md
@@ -65,12 +65,13 @@ Make the variable created store the current value and append the word to it.
##  Intermediate Code Solution:
function repeatStringNumTimes(str, num) {
- if(num < 0)
+ if (num < 1) {
return "";
- if(num === 1)
+ } else if (num === 1) {
return str;
- else
+ } else {
return str + repeatStringNumTimes(str, num - 1);
+ }
}
 Run Code