Skip to content

Commit a59de40

Browse files
Implement repeat function to handle string repetition with error handling for negative counts
1 parent 7429d54 commit a59de40

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
function repeat() {
2-
return "hellohellohello";
1+
function repeat(str,count) {
2+
if(count<0){
3+
return "Error: negative numbers are not valid";
4+
}
5+
return (str.repeat(count));
36
}
47

58
module.exports = repeat;
9+
10+
11+

0 commit comments

Comments
 (0)