-
-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy pathrepeat-str.js
More file actions
38 lines (37 loc) · 1.15 KB
/
repeat-str.js
File metadata and controls
38 lines (37 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function repeatStr(n, str) {
let result = "";
for (let i = 0; i < n; i++) {
result += str;
}
return result;
}
module.exports = repeatStr;
// const repeatStr = require("./repeat-str");
// Given a target string `str` and a positive integer `count`,
// When the repeatStr function is called with these inputs,
// Then it should:
// test("repeats a string n times", () => {
// expect(repeatStr(3, "hello")).toBe("hellohellohello");
// });
const repeatStr = require("./repeat-str");
test("repeats a string n times", () => {
expect(repeatStr(3, "hello")).toBe("hellohellohello");
});
// test("repeats a different string", () => {
// expect(repeatStr(2, "abc")).toBe("abcabc");
// });
test("repeats a different string", () => {
expect(repeatStr(2, "abc")).toBe("abcabc");
});
// test("returns empty string when n is 0", () => {
// expect(repeatStr(0, "hi")).toBe("");
// });
test("returns empty string when n is 0", () => {
expect(repeatStr(0, "hi")).toBe("");
});
// test("returns empty string when n is 0", () => {
// expect(repeatStr(0, "hi")).toBe("");
// });
test("returns empty string when n is 0", () => {
expect(repeatStr(0, "hi")).toBe("");
});