Skip to content

Commit 9c86871

Browse files
refactor repeat function to enhance input validation for string type
1 parent b91f950 commit 9c86871

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
function repeat(str, count) {
2+
if (typeof str !== "string") {
3+
return "Error: str must be a string";
4+
}
25
if (count < 0 || count === undefined || typeof count !== "number") {
36
return "Error : count must be a positive integer";
47
}

0 commit comments

Comments
 (0)