Skip to content

Commit 62a181f

Browse files
committed
Remove practice-tdd changes from this PR
1 parent 9a77853 commit 62a181f

6 files changed

Lines changed: 4 additions & 99 deletions

File tree

‎practice-tdd/count.js‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
export function countChar(stringOfCharacters, findCharacter) {
2-
let count = 0;
3-
for (const char of stringOfCharacters) {
4-
if (char === findCharacter) {
5-
count++;
6-
}
7-
}
8-
return count;
2+
return 5
93
}

‎practice-tdd/count.test.js‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +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 for a character with no occurrences", () => {
27-
const str = "aaaaa";
28-
const char = "b";
29-
const count = countChar(str, char);
30-
expect(count).toEqual(0);
31-
});

‎practice-tdd/get-ordinal-number.js‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
11
export function getOrdinalNumber(num) {
2-
const lastDigit = num % 10;
3-
const lastTwoDigit = num % 100;
4-
5-
if (lastDigit === 1 && lastTwoDigit !== 11) {
6-
return `${num}st`;
7-
}
8-
if (lastDigit === 2 && lastTwoDigit !== 12) {
9-
return `${num}nd`;
10-
}
11-
if (lastDigit === 3 && lastTwoDigit !== 13) {
12-
return `${num}rd`;
13-
}
14-
return `${num}th`;
2+
return "1st";
153
}

‎practice-tdd/get-ordinal-number.test.js‎

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,48 +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-
22-
// Case 2: Numbers ending with 2 (but not 12)
23-
// When the number ends with 2, except those ending with 12,
24-
// Then the function should return a string by appending "nd" to the number.
25-
test("should append 'nd' for numbers ending with 2, except those ending with 12", () => {
26-
expect(getOrdinalNumber(2)).toEqual("2nd");
27-
expect(getOrdinalNumber(22)).toEqual("22nd");
28-
expect(getOrdinalNumber(132)).toEqual("132nd");
29-
});
30-
31-
// Case 3: Numbers ending with 3 (but not 13)
32-
// When the number ends with 3, except those ending with 13,
33-
// Then the function should return a string by appending "rd" to the number.
34-
test("should append 'rd' for numbers ending with 3, except those ending with 13", () => {
35-
expect(getOrdinalNumber(3)).toEqual("3rd");
36-
expect(getOrdinalNumber(23)).toEqual("23rd");
37-
expect(getOrdinalNumber(133)).toEqual("133rd");
38-
});
39-
40-
// Case 4: Exception for 11, 12 and 13.
41-
// When a number ends with 11, 12 and 13,
42-
// Then the function should return a string by appending "th" not st, nd or rd.
43-
test("should append 'th' for numbers ending with 11, 12 and 13", () => {
44-
expect(getOrdinalNumber(11)).toEqual("11th");
45-
expect(getOrdinalNumber(12)).toEqual("12th");
46-
expect(getOrdinalNumber(13)).toEqual("13th");
47-
});
48-
49-
// Case 5: Numbers ending with 4 to 9.
50-
// When the number ends with 4 to 9,
51-
// Then the function should return a string by appending "th" to the number.
52-
test("should append 'th' for numbers ending with 4 to 9", () => {
53-
expect(getOrdinalNumber(4)).toEqual("4th");
54-
expect(getOrdinalNumber(14)).toEqual("14th");
55-
expect(getOrdinalNumber(144)).toEqual("144th");
56-
});
57-
58-
// Case 6: Numbers ending with 0.
59-
// When the number ends with 0,
60-
// Then the function should return a string by appending "th" to the number.
61-
test("should append 'th' for numbers ending with 0", () => {
62-
expect(getOrdinalNumber(0)).toEqual("0th");
63-
expect(getOrdinalNumber(10)).toEqual("10th");
64-
expect(getOrdinalNumber(100)).toEqual("100th");
65-
});

‎practice-tdd/repeat-str.js‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
export function repeatStr(str, count) {
1+
export function repeatStr() {
22
// Your implementation of this function must *not* call String.prototype.repeat (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat).
33
// The goal is to re-implement that function, not to use it.
4-
if (count < 0) {
5-
throw new Error("Count must not be negative");
6-
}
7-
8-
let repeat = "";
9-
for (let i = 0; i < count; i++) {
10-
repeat += str;
11-
}
12-
return repeat;
4+
return "hellohellohello";
135
}

‎practice-tdd/repeat-str.test.js‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +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 repeat the string count times", () => {
24-
const str = "hello";
25-
const count = 1;
26-
const repeatedStr = repeatStr(str, count);
27-
expect(repeatedStr).toEqual("hello");
28-
});
2923

3024
// Case: Handle count of 0:
3125
// Given a target string `str` and a `count` equal to 0,
3226
// When the repeatStr function is called with these inputs,
3327
// Then it should return an empty string.
34-
test("should return an empty string", () => {
35-
const str = "hello";
36-
const count = 0;
37-
const repeatedStr = repeatStr(str, count);
38-
expect(repeatedStr).toEqual("");
39-
});
4028

4129
// Case: Handle negative count:
4230
// Given a target string `str` and a negative integer `count`,
4331
// When the repeatStr function is called with these inputs,
4432
// Then it should throw an error, as negative counts are not valid.
45-
test("should throw an error", () => {
46-
const str = "hello";
47-
const count = -1;
48-
expect(() => repeatStr(str, count)).toThrow("Count must not be negative");
49-
});

0 commit comments

Comments
 (0)