Skip to content

Commit f9bca95

Browse files
authored
Refactor repeatStr to use parameters and add error handling
Refactor repeatStr function to accept parameters for string and count, and add error handling for invalid count.
1 parent cad1f0d commit f9bca95

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() {
2+
// return "hellohellohello";
3+
function repeatStr(str, count) {
4+
if (count >= 0) return str.repeat(count);
5+
else throw new Error("Invalid format: count cannot be");
36
}
47

58
module.exports = repeatStr;

0 commit comments

Comments
 (0)