We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b3404b7 commit 452b1a6Copy full SHA for 452b1a6
Sprint-3/2-practice-tdd/repeat.js
@@ -1,5 +1,15 @@
1
-function repeat() {
2
- return "hellohellohello";
+function repeat(str, count) {
+ 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);
10
}
11
12
module.exports = repeat;
13
14
15
+// Function implemented to repeat string count times.
0 commit comments