Skip to content

Commit 3585be7

Browse files
author
Payman IB
committed
Fix repeat function to throw an error for negative counts instead of returning a message
1 parent fbacf4a commit 3585be7

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function repeat(str , count) {
22
if (count < 0) {
3-
return "Count must be a non-negative integer";
3+
throw new Error("Count must be a non-negative integer");
44
}
55
if (count === 0) {
66
return "";
@@ -12,5 +12,4 @@ function repeat(str , count) {
1212
console.log(repeat("hello", -2));
1313

1414

15-
1615
module.exports = repeat;

0 commit comments

Comments
 (0)