Skip to content

Commit bb5dd83

Browse files
authored
Refactor repeatStr function by cleaning up code
Removed unnecessary checks for zero and commented-out test cases.
1 parent 6230cc6 commit bb5dd83

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ function repeatStr(str, num) {
33
var i;
44
if (num < 0) {
55
throw new Error("negative numbers are not valid");
6-
} else if (num === 0) {
7-
result = "";
86
} else {
97
for (i = 0; i < num; i++) {
108
result += str;
@@ -13,8 +11,4 @@ function repeatStr(str, num) {
1311
return result;
1412
}
1513

16-
//console.log(repeatStr("hello", -1));
17-
//console.log(repeatStr("hello", 0));
18-
//console.log(repeatStr("hello", 5))
19-
20-
module.exports = repeatStr;
14+
module.exports = repeatStr;

0 commit comments

Comments
 (0)