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 fea77f0 commit eac5a16Copy full SHA for eac5a16
1 file changed
Sprint-3/2-practice-tdd/repeat.js
@@ -1,20 +1,20 @@
1
function repeat(str, count) {
2
let newStr = "";
3
4
+ if (count < 0) {
5
+ throw new Error(
6
+ "Error invalid count used, please use integers from 0 upwards."
7
+ );
8
+ }
9
+
10
if (count === 0) {
11
return newStr;
- } else if (count === 1) {
- return str;
- } else if (count > 1) {
12
13
+ if (count > 0) {
14
for (let i = 0; i < count; i++) {
15
newStr += str;
16
}
17
- } else {
- throw new Error(
- "Error invalid count used, please use integers from 0 upwards."
- );
- //return "Error invalid count used, please use integers from 0 upwards.";
18
19
20
0 commit comments