Skip to content

Commit 485bd79

Browse files
authored
Update repeat-str.js
1 parent cd39358 commit 485bd79

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
function repeatStr(str, count) {
22
// Your implementation of this function must *not* call String.prototype.repeat (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat).
33
// The goal is to re-implement that function, not to use it.
4-
if (count === 1) {
5-
return str;
6-
7-
} else if (count < 0) {
4+
if (count < 0) {
85
throw new Error("Something went wrong");
96

107
} else if (count === 0) {
@@ -14,3 +11,5 @@ function repeatStr(str, count) {
1411
return Array.from({ length: count }, () => str).join("");
1512
}
1613
}
14+
15+
module.exports = repeatStr;

0 commit comments

Comments
 (0)