Skip to content

Commit 31a753f

Browse files
committed
Implement repeat str function
1 parent d675e73 commit 31a753f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
function repeatStr() {
2-
return "hellohellohello";
1+
function repeatStr(str, count) {
2+
if (typeof str !== "string")
3+
throw new Error("Please use a string i.e. 'Hello World'");
4+
5+
if (!Number.isInteger(count))
6+
throw new Error("Please set count to an integer");
7+
8+
if (count < 0) throw new Error("Please use a count of 0 or greater");
9+
10+
return str.repeat(count);
311
}
412

513
module.exports = repeatStr;

0 commit comments

Comments
 (0)