Skip to content

Commit 452b1a6

Browse files
committed
Function implemented to repeat string count times.
1 parent b3404b7 commit 452b1a6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
function repeat() {
2-
return "hellohellohello";
1+
function repeat(str, count) {
2+
if (typeof str !== "string") {
3+
throw new Error("Input must be a string");
4+
}
5+
if (!Number.isInteger(count) || count < 0) {
6+
throw new Error("Count must be a non-negative integer");
7+
}
8+
9+
return str.repeat(count);
310
}
411

512
module.exports = repeat;
13+
14+
15+
// Function implemented to repeat string count times.

0 commit comments

Comments
 (0)