Skip to content

Commit c46fdb0

Browse files
updated function to handle 0 and negative numbers
1 parent 31cfb33 commit c46fdb0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
function repeatStr() {
2-
return "hellohellohello";
1+
function repeatStr(str, count) {
2+
if (count < 0) {
3+
throw new Error("Only positive integers accepted");
4+
}
5+
return str.repeat(count);
36
}
47

58
module.exports = repeatStr;

0 commit comments

Comments
 (0)