Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c4261fd
if condition created inside getAngleType function to evaluate the typ…
Jul 4, 2026
3331c94
Test cases for Right and Obtuse angles created.
Jul 7, 2026
d16b7fb
Test cases for Straight, Reflex and Invalid angles created and tested.
Jul 7, 2026
c3617ce
More test cases added for invalid angles including negative numbers.
Jul 7, 2026
29fc3b3
A return expression added into isProperFraction function
Jul 7, 2026
94c1f50
Test case for no occurrences scenario for a char in a str created.
Jul 14, 2026
d4edc9d
Test case for handling 0 and negative counts of a char in a str created.
Jul 14, 2026
e82f88c
Test cases for handling different ordinal numbers created.
Jul 14, 2026
1fa6def
countChar function created to check for multiple occurrence of a char…
Jul 14, 2026
d37292b
.length method added to count char in a str
Jul 14, 2026
8253891
repeatStr function created to check count times is str repeated.
Jul 14, 2026
8979be1
Unnecessary code removed.
Jul 14, 2026
0e19677
Test case to handle negative numbers and throw an error fixed.
Jul 21, 2026
74d5e9f
Function for first test case fir checking numbers ending with st impl…
Jul 21, 2026
42025c9
A second if statement added into the function to check tests for numb…
Jul 21, 2026
ee69e69
A third if statement added to test numbers with ending in rd
Jul 21, 2026
3590fb1
An if statement added to the function to check if num is not negative…
Jul 21, 2026
2399760
Redundant code removed
Jul 28, 2026
d99d5b9
Unused code removed
Jul 28, 2026
d3f4e1a
Work committed without creating a new branch
Jul 28, 2026
ae0db8c
Files updated that were committed on the wrong branch
Jul 28, 2026
c466f3f
file removed from the wrong branch
Jul 28, 2026
2d60a0f
Branch updated
Jul 28, 2026
9edf029
branch updated
Jul 28, 2026
8662965
branch updated
Jul 29, 2026
954144d
branch updated
Jul 29, 2026
475c68f
k
Jul 30, 2026
457f1a7
files removed
Jul 30, 2026
a19d129
files updated
Jul 30, 2026
17367af
Remove untracked files from branch
Jul 30, 2026
356a851
files changed
Jul 30, 2026
6f5a3e7
Restore untouched files to match main
Jul 30, 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
9 changes: 8 additions & 1 deletion Sprint-3/2-practice-tdd/count.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
function countChar(stringOfCharacters, findCharacter) {
return 5
let count = 0;

for (let i = 0; i < stringOfCharacters.length; i++) {
if (stringOfCharacters[i] === findCharacter) {
count++;
}
}
return count;
}

module.exports = countChar;
7 changes: 7 additions & 0 deletions Sprint-3/2-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 when if no occurrences of a character", () => {
const str = "cc";
const char = "b";
const count = countChar(str, char);
expect(count).toEqual(0);
});
16 changes: 15 additions & 1 deletion Sprint-3/2-practice-tdd/get-ordinal-number.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
function getOrdinalNumber(num) {
return "1st";
if (num <= 0 || !Number.isInteger(num) || typeof num !== "number") {
return "error";
}
const lastDigit = num % 10;
const lastTwoDigits = num % 100;
if (lastDigit === 1 && lastTwoDigits !== 11) {
return `${num}st`;
}
if (lastDigit === 2 && lastTwoDigits !== 12) {
return `${num}nd`;
}
if (lastDigit === 3 && lastTwoDigits !== 13) {
return `${num}rd`;
}
return `${num}th`;
}

module.exports = getOrdinalNumber;
31 changes: 31 additions & 0 deletions Sprint-3/2-practice-tdd/get-ordinal-number.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,34 @@ test("should append 'st' for numbers ending with 1, except those ending with 11"
expect(getOrdinalNumber(21)).toEqual("21st");
expect(getOrdinalNumber(131)).toEqual("131st");
});

test("should append 'nd' for numbers ending with 2", () => {
expect(getOrdinalNumber(2)).toEqual("2nd");
expect(getOrdinalNumber(22)).toEqual("22nd");
expect(getOrdinalNumber(132)).toEqual("132nd");
});

test("should append 'rd' for numbers ending with 3", () => {
expect(getOrdinalNumber(3)).toEqual("3rd");
expect(getOrdinalNumber(23)).toEqual("23rd");
expect(getOrdinalNumber(133)).toEqual("133rd");
});

test("should append 'th' for numbers ending with 4 -10", () => {
expect(getOrdinalNumber(4)).toEqual("4th");
expect(getOrdinalNumber(7)).toEqual("7th");
expect(getOrdinalNumber(10)).toEqual("10th");
});

test("should append 'th' for numbers ending with 11 - 13", () => {
expect(getOrdinalNumber(11)).toEqual("11th");
expect(getOrdinalNumber(12)).toEqual("12th");
expect(getOrdinalNumber(13)).toEqual("13th");
});

test("should append 'error' for invalid numbers", () => {
expect(getOrdinalNumber(0)).toEqual("error");
expect(getOrdinalNumber(-1)).toEqual("error");
expect(getOrdinalNumber(1.5)).toEqual("error");
expect(getOrdinalNumber("5")).toEqual("error");
});
14 changes: 11 additions & 3 deletions Sprint-3/2-practice-tdd/repeat-str.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
function repeatStr() {
function repeatStr(str, count) {
if (count < 0) {
throw new Error("Error");
}
// 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";
//The goal is to re-implement that function, not to use it.
let repeatedStr = "";

for (let i = 0; i < count; i++) {
repeatedStr += str;
}
return repeatedStr;
}

module.exports = repeatStr;
20 changes: 20 additions & 0 deletions Sprint-3/2-practice-tdd/repeat-str.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,32 @@ test("should repeat the string count times", () => {
// When the repeatStr function is called with these inputs,
// Then it should return the original `str` without repetition.

test("should repeat the string count 1 time", () => {
const str = "hi";
const count = 1;
const repeatedStr = repeatStr(str, count);
expect(repeatedStr).toEqual("hi");
});

// 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 repeat the string 0 time", () => {
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(() => repeatedStr(str, count)).toThrow();
});
Loading