Skip to content

Commit a893b09

Browse files
committed
removing practice-tdd from branch
1 parent c1a3f24 commit a893b09

File tree

6 files changed

+6
-92
lines changed

6 files changed

+6
-92
lines changed

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
function countChar(stringOfCharacters, findCharacter) {
2-
//
3-
let count = 0;
4-
for (let i = 0; i < stringOfCharacters.length; i++) {
5-
if (stringOfCharacters[i] === findCharacter) {
6-
count++;
7-
}
8-
}
9-
return count;
2+
return 5
103
}
114

125
module.exports = countChar;

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,3 @@ test("should count multiple occurrences of a character", () => {
2222
// And a character `char` that does not exist within `str`.
2323
// When the function is called with these inputs,
2424
// Then it should return 0, indicating that no occurrences of `char` were found.
25-
26-
test("should return 0 when character does not occur in string", () => {
27-
const str = "hello world";
28-
const char = "x";
29-
const count = countChar(str, char);
30-
expect(count).toEqual(0);
31-
});
32-
Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
function getOrdinalNumber(num) {
2-
// return "1st";
3-
if (num % 100 >= 11 && num % 100 <= 13) {
4-
return num + "th";
5-
}
6-
if (num % 10 === 1) {
7-
return num + "st";
8-
}
9-
if (num % 10 === 2) {
10-
return num + "nd";
11-
}
12-
if (num % 10 === 3) {
13-
return num + "rd";
14-
}
15-
return num + "th";
2+
return "1st";
163
}
174

185
module.exports = getOrdinalNumber;

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

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,3 @@ test("should append 'st' for numbers ending with 1, except those ending with 11"
1818
expect(getOrdinalNumber(21)).toEqual("21st");
1919
expect(getOrdinalNumber(131)).toEqual("131st");
2020
});
21-
// Case 2: Numbers ending with 2 (but not 12)
22-
// When the number ends with 2, except those ending with 12,
23-
// Then the function should return a string by appending "nd" to the number.
24-
test("should append 'nd' for numbers ending with 2, except those ending with 12", () => {
25-
expect(getOrdinalNumber(2)).toEqual("2nd");
26-
expect(getOrdinalNumber(22)).toEqual("22nd");
27-
expect(getOrdinalNumber(132)).toEqual("132nd");
28-
});
29-
// Case 3: Numbers ending with 3 (but not 13)
30-
// When the number ends with 3, except those ending with 13,
31-
// Then the function should return a string by appending "rd" to the number.
32-
test("should append 'rd' for numbers ending with 3, except those ending with 13", () => {
33-
expect(getOrdinalNumber(3)).toEqual("3rd");
34-
expect(getOrdinalNumber(23)).toEqual("23rd");
35-
expect(getOrdinalNumber(133)).toEqual("133rd");
36-
});
37-
// Case 4: Numbers ending with 11, 12, or 13
38-
// When the number ends with 11, 12, or 13,
39-
// Then the function should return a string by appending "th" to the number.
40-
test("should append 'th' for numbers ending with 11, 12, or 13", () => {
41-
expect(getOrdinalNumber(11)).toEqual("11th");
42-
expect(getOrdinalNumber(12)).toEqual("12th");
43-
expect(getOrdinalNumber(13)).toEqual("13th");
44-
expect(getOrdinalNumber(111)).toEqual("111th");
45-
expect(getOrdinalNumber(112)).toEqual("112th");
46-
expect(getOrdinalNumber(113)).toEqual("113th");
47-
});
48-
// Case 5: All other numbers
49-
// When the number does not end with 1, 2, or 3 (and is not 11, 12, or 13),
50-
// Then the function should return a string by appending "th" to the number.
51-
test("should append 'th' for all other numbers", () => {
52-
expect(getOrdinalNumber(4)).toEqual("4th");
53-
expect(getOrdinalNumber(10)).toEqual("10th");
54-
expect(getOrdinalNumber(14)).toEqual("14th");
55-
expect(getOrdinalNumber(100)).toEqual("100th");
56-
});
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
function repeatStr(str, count) {
2-
if (count < 0) {
3-
throw new Error("Count must be a non-negative integer");
4-
}
5-
let result = "";
6-
for (let i = 0; i < count; i++) {
7-
result += str;
8-
}
9-
return result;
1+
function repeatStr() {
2+
return "hellohellohello";
103
}
114

125
module.exports = repeatStr;

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,13 @@ test("should repeat the string count times", () => {
2020
// Given a target string `str` and a `count` equal to 1,
2121
// When the repeatStr function is called with these inputs,
2222
// Then it should return the original `str` without repetition.
23-
test("should return the original string when count is 1", () => {
24-
const str = "hello";
25-
const count = 1;
26-
const repeatedStr = repeatStr(str, count);
27-
expect(repeatedStr).toEqual("hello");
28-
});
23+
2924
// Case: Handle count of 0:
3025
// Given a target string `str` and a `count` equal to 0,
3126
// When the repeatStr function is called with these inputs,
3227
// Then it should return an empty string.
33-
test("should return an empty string when count is 0", () => {
34-
const str = "hello";
35-
const count = 0;
36-
const repeatedStr = repeatStr(str, count);
37-
expect(repeatedStr).toEqual("");
38-
});
28+
3929
// Case: Handle negative count:
4030
// Given a target string `str` and a negative integer `count`,
4131
// When the repeatStr function is called with these inputs,
4232
// Then it should throw an error, as negative counts are not valid.
43-
test("should throw an error when count is negative", () => {
44-
const str = "hello";
45-
const count = -1;
46-
expect(() => repeatStr(str, count)).toThrow("Count must be a non-negative integer");
47-
} );

0 commit comments

Comments
 (0)