Skip to content

Commit eac5a16

Browse files
committed
removed unnecessary code from function
1 parent fea77f0 commit eac5a16

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
function repeat(str, count) {
22
let newStr = "";
33

4+
if (count < 0) {
5+
throw new Error(
6+
"Error invalid count used, please use integers from 0 upwards."
7+
);
8+
}
9+
410
if (count === 0) {
511
return newStr;
6-
} else if (count === 1) {
7-
return str;
8-
} else if (count > 1) {
12+
}
13+
if (count > 0) {
914
for (let i = 0; i < count; i++) {
1015
newStr += str;
1116
}
1217
return newStr;
13-
} else {
14-
throw new Error(
15-
"Error invalid count used, please use integers from 0 upwards."
16-
);
17-
//return "Error invalid count used, please use integers from 0 upwards.";
1818
}
1919
}
2020

0 commit comments

Comments
 (0)