Skip to content

Commit 1c394fb

Browse files
Implement repeatStr function to return repeated string based on count, with error handling for negative counts
1 parent d4b7e36 commit 1c394fb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
function repeatStr() {
2-
return "hellohellohello";
1+
function repeatStr(str, count) {
2+
if (count < 0) throw new Error("negative counts are not valid");
3+
return str.repeat(count);
34
}
45

56
module.exports = repeatStr;

0 commit comments

Comments
 (0)