Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
301ea63
List edge cases for test.
Sep 28, 2026
2501561
Update list.
Sep 28, 2026
63e477b
Add an if condition to check midnight
Sep 28, 2026
a8e1b2d
Add another case to test midnight
Sep 28, 2026
9e2cef8
Add test case 00:01 to 12:01 am
Sep 28, 2026
2ba2e34
Add condition for checking midday 12 pm
Sep 28, 2026
06d5f91
Add test case for 01:00 to 01:00 am
Sep 28, 2026
3dc6da6
Add test case for 11:59 to 11:59 am
Sep 28, 2026
1e6cb55
Add test case for 12:01 to 12:01 pm
Sep 28, 2026
61b2ce7
Add test case for 13:00 to 1:00 pm
Sep 28, 2026
0407869
Add test case fo 23:59 to 11:59 pm
Sep 28, 2026
06d3f9a
Add padStart method to hours
Sep 28, 2026
598f744
Add more description.
Sep 28, 2026
e6fde3b
Add padStart method to convert 23:00 to 01:00pm
Sep 29, 2026
c2f743c
Edit comments
Sep 29, 2026
e7ff9c7
Inline code directly into return statement
Sep 30, 2026
751fb78
Change am and pm to lower case and update description.
Sep 30, 2026
4707f5a
Unreachable code.
Sep 30, 2026
f504687
Remove unreachable and redundant code.
Sep 30, 2026
d9197c4
Remove unused code
Sep 30, 2026
9494c3d
Update function to work for any input.
Sep 30, 2026
582699c
Format code with prettier.
Sep 30, 2026
b806b41
Stop tracking files
Oct 3, 2026
fcf27e7
Stop tracking files
Oct 3, 2026
04f544f
Restore files unrelated to this PR
Oct 3, 2026
4815e87
Add if condition for checking right angle.
Oct 3, 2026
9dc9e1f
Write test for Acute angle.
Oct 3, 2026
10b0d0f
Write test for Obtuse angle.
Oct 3, 2026
cccf002
Add if condition for checking Acute angle.
Oct 3, 2026
ed2729e
Add if condition for checking Obtuse angle.
Oct 3, 2026
4fa3e6c
Write test for invalid angles
Oct 3, 2026
ea5fa0f
Add final if condition for checking invalid angle
Oct 3, 2026
6102a89
Add boundary case test for acute angle.
Oct 4, 2026
717584d
Add if condition for checking invalid inputs.
Oct 4, 2026
fed8ddd
Add boundary test cases for multiple angles.
Oct 4, 2026
bb815ef
Add = operator for checking 360 degrees is included
Oct 4, 2026
c8fc9dd
Add boundary test cases.
Oct 5, 2026
3a565e9
Add angle type boundary tests
Oct 5, 2026
c80ed87
Add angle type boundary tests
Oct 5, 2026
38c28b3
Implement if condition to check propr function.
Oct 5, 2026
f12c635
Delete not needed test.
Oct 6, 2026
48b8dae
Write cases for testing proper and improper fractions.
Oct 6, 2026
d5091de
Update tests description.
Oct 6, 2026
fa07e40
Implement if condition to check card value
Oct 7, 2026
71c6ea1
Write to test 0 occurrence of a character.
russom-g Oct 13, 2026
c12bed8
Implement function to check character occurrence in a string.
russom-g Oct 13, 2026
1b777bf
Refactor code.
russom-g Oct 13, 2026
5d29d04
Update test description.
russom-g Oct 13, 2026
63905f0
Write test case for numbers ending with 2
russom-g Oct 14, 2026
be0c56e
Write test cases for testing numbers ending with 2.
russom-g Oct 14, 2026
f05ab1d
Write test cases for testing numbers ending with 3.
russom-g Oct 14, 2026
d6e7d06
Write test cases for numbers ending with rd and th.
russom-g Oct 14, 2026
2431fdf
Update test description.
russom-g Oct 14, 2026
7421372
Implement a function for checking ordinal numbers and their suffixes.
russom-g Oct 14, 2026
51a7234
Refactor test cases.
russom-g Oct 14, 2026
7465a37
Write test case for repeating 1 times
russom-g Oct 15, 2026
b5ed6ae
Write test case for repeating 0 times.
russom-g Oct 15, 2026
d363d13
Write test case for repeating -1 times.
russom-g Oct 15, 2026
bd5de48
Implement function that repeats string a number of times.
russom-g Oct 16, 2026
616bbbf
Write test case to test negative input.
russom-g Oct 16, 2026
2de2d40
Remove exercise folders from repo
russom-g Oct 16, 2026
05f3e6e
Restore files to state before removal
russom-g Oct 16, 2026
ba2ebd0
Restore practice-tdd work and remove files from other branches
russom-g Oct 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion practice-tdd/count.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
export function countChar(stringOfCharacters, findCharacter) {
return 5
let count = 0;
for (const char of stringOfCharacters) {
if (char === findCharacter) {
count++;
}
}
return count;
}
7 changes: 7 additions & 0 deletions practice-tdd/count.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ test("should count multiple occurrences of a character", () => {
// And a character `char` that does not exist within `str`.
// When the function is called with these inputs,
// Then it should return 0, indicating that no occurrences of `char` were found.

test("should return 0 for a character with no occurrences", () => {
const str = "aaaaa";
const char = "b";
const count = countChar(str, char);
expect(count).toEqual(0);
});
14 changes: 13 additions & 1 deletion practice-tdd/get-ordinal-number.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
export function getOrdinalNumber(num) {
return "1st";
const lastDigit = num % 10;
const lastTwoDigit = num % 100;

if (lastDigit === 1 && lastTwoDigit !== 11) {
return `${num}st`;
}
if (lastDigit === 2 && lastTwoDigit !== 12) {
return `${num}nd`;
}
if (lastDigit === 3 && lastTwoDigit !== 13) {
return `${num}rd`;
}
return `${num}th`;
}
45 changes: 45 additions & 0 deletions practice-tdd/get-ordinal-number.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,48 @@ test("should append 'st' for numbers ending with 1, except those ending with 11"
expect(getOrdinalNumber(21)).toEqual("21st");
expect(getOrdinalNumber(131)).toEqual("131st");
});

// Case 2: Numbers ending with 2 (but not 12)
// When the number ends with 2, except those ending with 12,
// Then the function should return a string by appending "nd" to the number.
test("should append 'nd' for numbers ending with 2, except those ending with 12", () => {
expect(getOrdinalNumber(2)).toEqual("2nd");
expect(getOrdinalNumber(22)).toEqual("22nd");
expect(getOrdinalNumber(132)).toEqual("132nd");
});

// Case 3: Numbers ending with 3 (but not 13)
// When the number ends with 3, except those ending with 13,
// Then the function should return a string by appending "rd" to the number.
test("should append 'rd' for numbers ending with 3, except those ending with 13", () => {
expect(getOrdinalNumber(3)).toEqual("3rd");
expect(getOrdinalNumber(23)).toEqual("23rd");
expect(getOrdinalNumber(133)).toEqual("133rd");
});

// Case 4: Exception for 11, 12 and 13.
// When a number ends with 11, 12 and 13,
// Then the function should return a string by appending "th" not st, nd or rd.
test("should append 'th' for numbers ending with 11, 12 and 13", () => {
expect(getOrdinalNumber(11)).toEqual("11th");
expect(getOrdinalNumber(12)).toEqual("12th");
expect(getOrdinalNumber(13)).toEqual("13th");
});

// Case 5: Numbers ending with 4 to 9.
// When the number ends with 4 to 9,
// Then the function should return a string by appending "th" to the number.
test("should append 'th' for numbers ending with 4 to 9", () => {
expect(getOrdinalNumber(4)).toEqual("4th");
expect(getOrdinalNumber(14)).toEqual("14th");
expect(getOrdinalNumber(144)).toEqual("144th");
});

// Case 6: Numbers ending with 0.
// When the number ends with 0,
// Then the function should return a string by appending "th" to the number.
test("should append 'th' for numbers ending with 0", () => {
expect(getOrdinalNumber(0)).toEqual("0th");
expect(getOrdinalNumber(10)).toEqual("10th");
expect(getOrdinalNumber(100)).toEqual("100th");
});
12 changes: 10 additions & 2 deletions practice-tdd/repeat-str.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
export function repeatStr() {
export function repeatStr(str, count) {
// 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).
// The goal is to re-implement that function, not to use it.
return "hellohellohello";
if (count < 0) {
throw new Error("Count must not be negative");
}

let repeat = "";
for (let i = 0; i < count; i++) {
repeat += str;
}
return repeat;
}
17 changes: 17 additions & 0 deletions practice-tdd/repeat-str.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,30 @@ test("should repeat the string count times", () => {
// Given a target string `str` and a `count` equal to 1,
// When the repeatStr function is called with these inputs,
// Then it should return the original `str` without repetition.
test("should repeat the string count times", () => {
const str = "hello";
const count = 1;
const repeatedStr = repeatStr(str, count);
expect(repeatedStr).toEqual("hello");
});

// Case: Handle count of 0:
// Given a target string `str` and a `count` equal to 0,
// When the repeatStr function is called with these inputs,
// Then it should return an empty string.
test("should return an empty string", () => {
const str = "hello";
const count = 0;
const repeatedStr = repeatStr(str, count);
expect(repeatedStr).toEqual("");
});

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