Skip to content

Commit 66efc47

Browse files
committed
Added repeat function with negative count check
1 parent b58f10c commit 66efc47

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
function repeat() {
2-
return "hellohellohello";
1+
function repeat(str, count) {
2+
if (count < 0){
3+
throw new Error("count cannot be negative");
4+
}
5+
6+
return str.repeat(count);
37
}
48

59
module.exports = repeat;

0 commit comments

Comments
 (0)