Skip to content

Commit e063f79

Browse files
committed
practice tdd repeat
1 parent 992821e commit e063f79

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
function repeat() {
2-
return "hellohellohello";
1+
function repeat(str, count) {
2+
if (count < 0) {
3+
throw new Error("Count must be non-negative");
4+
}
5+
6+
let result = "";
7+
for (let i = 0; i < count; i++) {
8+
result += str;
9+
}
10+
return result;
311
}
412

513
module.exports = repeat;

0 commit comments

Comments
 (0)