Skip to content

Commit 5458a92

Browse files
committed
Update function for 2-practice-tdd/repeat.str.js
1 parent e3f5cd6 commit 5458a92

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ function repeatStr(str, count) {
66
throw new Error("Number must be 0 or greater");
77
}
88

9-
let repeatedStr = "";
10-
for (let i = 0; i < count; i++) {
11-
repeatedStr += str;
12-
}
13-
return repeatedStr;
9+
return new Array(count).fill(str).join("");
1410
}
1511

1612
module.exports = repeatStr;

0 commit comments

Comments
 (0)