Skip to content

Commit 0644d6f

Browse files
committed
In repeat-str.js now first testing if number is 0 already
1 parent 2256f87 commit 0644d6f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Sprint-3/2-practice-tdd/repeat-str.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ function repeatStr(str, count) {
22
if (count < 0) {
33
throw new Error("Negative counts are not valid");
44
}
5+
if (count === 0) {
6+
return "";
7+
}
58
let result = "";
69
for (let i = 0; i < count; i++) {
710
result += str;

0 commit comments

Comments
 (0)