Skip to content

Commit 0c6b25c

Browse files
authored
changes are made based on feedback
1 parent 9859d0d commit 0c6b25c

File tree

4 files changed

+28
-23
lines changed

4 files changed

+28
-23
lines changed

Sprint-3/2-practice-tdd/count.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ test("should count multiple occurrences of a character", () => {
3636
// And a character char that does not exist within the case-sensitive str,
3737
// When the function is called with these inputs,
3838
// Then it should return 0, indicating that no occurrences of the char were found in the case-sensitive str.
39+
test("should count multiple occurrences of a character", () => {
40+
const str = "hello";
41+
const char = "a";
42+
const count = countChar(str, char);
43+
expect(count).toEqual(0);
44+
});

Sprint-3/2-practice-tdd/get-ordinal-number.test.js

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,24 @@ const getOrdinalNumber = require("./get-ordinal-number");
77
// Case 1: Identify the ordinal number for 1
88
// When the number is 1,
99
// Then the function should return "1st"
10-
11-
test("should return '1st' for 1", () => {
12-
expect(getOrdinalNumber(1)).toEqual("1st");
13-
});
14-
15-
test("should return '2nd' for 2", () => {
16-
expect(getOrdinalNumber(2)).toEqual("2nd");
17-
});
18-
19-
test("should return '3rd' for 3", () => {
20-
expect(getOrdinalNumber(3)).toEqual("3rd");
21-
});
22-
23-
test("should return '11th' for 11", () => {
24-
expect(getOrdinalNumber(11)).toEqual("11th");
10+
test("append 'st' to numbers ending in 1, except those ending in 11 which is 11th", () => {
11+
expect( getOrdinalNumber(1) ).toEqual("1st");
12+
expect( getOrdinalNumber(11) ).toEqual("11th");
13+
expect( getOrdinalNumber(21) ).toEqual("21st");
14+
expect( getOrdinalNumber(221) ).toEqual("221st");
2515
});
2616

27-
test("should return '12th' for 12", () => {
28-
expect(getOrdinalNumber(12)).toEqual("12th");
17+
test("append 'nd' to numbers ending in 2, except those ending in 12 which is 12th", () => {
18+
expect( getOrdinalNumber(2) ).toEqual("2nd");
19+
expect( getOrdinalNumber(12) ).toEqual("12th");
20+
expect( getOrdinalNumber(22) ).toEqual("22nd");
21+
expect( getOrdinalNumber(132) ).toEqual("132nd");
2922
});
3023

31-
test("should return '13th' for 13", () => {
32-
expect(getOrdinalNumber(13)).toEqual("13th");
24+
test("append 'rd' to numbers ending in 3, except those ending in 13 which is 13th", () => {
25+
expect( getOrdinalNumber(3) ).toEqual("3rd");
26+
expect( getOrdinalNumber(13) ).toEqual("13th");
27+
expect( getOrdinalNumber(33) ).toEqual("33rd");
28+
expect( getOrdinalNumber(133) ).toEqual("133rd");
3329
});
3430

35-
test("should return '24th' for 14", () => {
36-
expect(getOrdinalNumber(24)).toEqual("24th");
37-
});

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
function repeat(word, n) {
2+
if (typeof n !== 'number' || n < 0) {
3+
return "Count must be a non-negative integer";
4+
}
5+
if (n === 0) {
6+
return " ";
7+
}
28
return word.repeat(n);
39
}
410

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ test("should repeat the string count times", () => {
4646
const str = "hello";
4747
const count = -1;
4848
const repeatedStr = repeat(str, count);
49-
expect(repeatedStr).toEqual("hellohellohello");
49+
expect(repeatedStr).toEqual("Count must be a non-negative integer");
5050
});

0 commit comments

Comments
 (0)