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 715c649 commit 2af6c11Copy full SHA for 2af6c11
Sprint-3/2-practice-tdd/repeat-str.js
@@ -1,5 +1,22 @@
1
-function repeatStr() {
2
- return "hellohellohello";
+function repeatStr(n, str) {
+ let result = "";
3
+ for (let i = 0; i < n; i++) {
4
+ result += str;
5
+ }
6
+ return result;
7
}
8
9
module.exports = repeatStr;
10
+const repeatStr = require("./repeat-str");
11
+
12
+test("repeats a string n times", () => {
13
+ expect(repeatStr(3, "hello")).toBe("hellohellohello");
14
+});
15
16
+test("repeats a different string", () => {
17
+ expect(repeatStr(2, "abc")).toBe("abcabc");
18
19
20
+test("returns empty string when n is 0", () => {
21
+ expect(repeatStr(0, "hi")).toBe("");
22
0 commit comments