Skip to content

Commit da793bd

Browse files
committed
practice-tdd files were updated
1 parent e73df46 commit da793bd

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function countChar(stringOfCharacters, findCharacter) {
99
numberOfChar++;
1010
}
1111
if (numberOfChar === 0) {
12-
return `0 ${findCharacter} found.`
12+
return 0;
1313
}
1414
}
1515
return numberOfChar;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ test("should return 0 if there is not a character occurrence", () => {
2626
const str = "aaaaa";
2727
const char = "b";
2828
const count = countChar(str, char);
29-
expect(count).toEqual(`0 ${char} found.`);
30-
});
29+
expect(count).toEqual(0);
30+
});

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
// lets develop our function.
22
function getOrdinalNumber(num) {
3-
43
const lastDigit = num % 10; // ==> 111 % 10 = 11.1 last digit is 1.
54
const lastTwoDigits = num % 100; // 111 % 100 = 111 last two digits 11.
6-
7-
if (lastTwoDigits >= 11 && lastTwoDigits <= 13){
8-
return `${num}th`;// ==> finds the last two digits to equal (11,12,13)
5+
6+
if (lastTwoDigits >= 11 && lastTwoDigits <= 13) {
7+
return `${num}th`; // ==> finds the last two digits to equal (11,12,13)
98
}
10-
if(lastDigit == 1){
9+
if (lastDigit == 1) {
1110
return `${num}st`;
12-
}else if (lastDigit == 2){
11+
} else if (lastDigit == 2) {
1312
return `${num}nd`;
14-
}else if (lastDigit == 3){
13+
} else if (lastDigit == 3) {
1514
return `${num}rd`;
1615
} else return `${num}th`;
1716
}

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@ test("should append 'rd' for numbers ending with 3, except those ending with 13"
2828
expect(getOrdinalNumber(33)).toEqual("33rd");
2929
expect(getOrdinalNumber(333)).toEqual("333rd");
3030
});
31-
test("should append 'th' for numbers ending with 4 and more than 4", () => {
31+
test("should append 'th' for numbers ending with 4-9 or 0 (except 11-13)", () => {
3232
expect(getOrdinalNumber(4)).toEqual("4th");
33-
expect(getOrdinalNumber(44)).toEqual("44th");
34-
expect(getOrdinalNumber(444)).toEqual("444th");
3533
expect(getOrdinalNumber(5)).toEqual("5th");
34+
expect(getOrdinalNumber(6)).toEqual("6th");
35+
expect(getOrdinalNumber(7)).toEqual("7th");
36+
expect(getOrdinalNumber(8)).toEqual("8th");
37+
expect(getOrdinalNumber(9)).toEqual("9th");
3638
expect(getOrdinalNumber(10)).toEqual("10th");
37-
expect(getOrdinalNumber(100)).toEqual("100th");
38-
expect(getOrdinalNumber(105)).toEqual("105th");
39+
expect(getOrdinalNumber(14)).toEqual("14th");
3940
});
4041
test("should append 'th' for numbers ending with 11, 12 and 13", () => {
4142
expect(getOrdinalNumber(11)).toEqual("11th");
4243
expect(getOrdinalNumber(12)).toEqual("12th");
4344
expect(getOrdinalNumber(13)).toEqual("13th");
44-
});
45+
});

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ test("should repeat the string count times", () => {
1717
// Given a target string `str` and a `count` equal to 1,
1818
// When the repeatStr function is called with these inputs,
1919
// Then it should return the original `str` without repetition.
20-
test("should print the original string", () => {
20+
test("should return the original string when count is 1", () => {
2121
expect(repeatStr("Love", 1)).toEqual("Love");
2222
});
2323
// Case: Handle count of 0:
2424
// Given a target string `str` and a `count` equal to 0,
2525
// When the repeatStr function is called with these inputs,
2626
// Then it should return an empty string.
27-
test("should return an empty string", () => {
27+
test("should return an empty string when count is 0", () => {
2828
expect(repeatStr("Love", 0)).toEqual("");
2929
});
3030
// Case: Handle negative count:
@@ -33,4 +33,4 @@ test("should return an empty string", () => {
3333
// Then it should throw an error, as negative counts are not valid.
3434
test("should throw and error when count is a negative number", () => {
3535
expect(() => repeatStr("Love", -3)).toThrow("Negative counts are not valid");
36-
});
36+
});

0 commit comments

Comments
 (0)