Skip to content
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b5de08b
build up getAngleType case by case
Alaa-Tagi Oct 9, 2025
b5fa562
Editing is-proper-fraction code
Alaa-Tagi Oct 9, 2025
3898643
Editing getcardvalue code
Alaa-Tagi Oct 12, 2025
78d374a
rewrite test with jest for getangletype code
Alaa-Tagi Oct 12, 2025
d07dd99
update isproperfraction code
Alaa-Tagi Oct 12, 2025
a223e45
Rewrite test with jest for isproperfraction code
Alaa-Tagi Oct 12, 2025
ef42f92
rewrite test with jest for getcardvalue code
Alaa-Tagi Oct 12, 2025
b02a77f
Editing count code
Alaa-Tagi Oct 12, 2025
3f11ed4
Editing count.js code
Alaa-Tagi Oct 12, 2025
d7507ff
Rewrite tests with jest for count code
Alaa-Tagi Oct 12, 2025
2eaa92c
Editing getordinalnumber code
Alaa-Tagi Oct 12, 2025
73c8fcf
Rewrite tests with jest for getordinalnumber code
Alaa-Tagi Oct 12, 2025
52660c9
Editing repeat code
Alaa-Tagi Oct 12, 2025
408f2e1
Rewrite test with jest for repeat code
Alaa-Tagi Oct 12, 2025
1f0b098
1-get-angle-type.js
Alaa-Tagi Oct 12, 2025
d276533
2-is-proper-fraction.js
Alaa-Tagi Oct 12, 2025
ce08a1f
3-get-card-value.js
Alaa-Tagi Oct 12, 2025
874c5ca
1-get-angle-type.test.js
Alaa-Tagi Oct 12, 2025
ea944a1
3-get-card-value.test.js
Alaa-Tagi Oct 12, 2025
d25945b
2-is-proper-fraction.test.js
Alaa-Tagi Oct 12, 2025
5e24460
Removes all console logs from PR
Alaa-Tagi Oct 24, 2025
d269acc
Editing the code and jest code
Alaa-Tagi Oct 24, 2025
62bf3a9
Editing jest code
Alaa-Tagi Oct 24, 2025
6f9d56b
update the code
Alaa-Tagi Oct 24, 2025
b1c0345
Write additional tests
Alaa-Tagi Oct 24, 2025
8ff02d3
Correct the code
Alaa-Tagi Oct 24, 2025
2aafdb6
Add another tests
Alaa-Tagi Oct 24, 2025
c491953
Remove all console logs
Alaa-Tagi Oct 26, 2025
0f0c704
editing the code
Alaa-Tagi Oct 26, 2025
9e74422
fixing the code to run the jest test
Alaa-Tagi Oct 26, 2025
099a76f
Deleting line to fix the code
Alaa-Tagi Oct 26, 2025
2db8252
editing the code
Alaa-Tagi Oct 27, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ const obtuse = getAngleType(120);
// Case 5: Identify Reflex Angles:
// When the angle is greater than 180 degrees and less than 360 degrees,
// Then the function should return "Reflex angle"
// ====> write your test here, and then add a line to pass the test in the function above
// ====> write your test here, and then add a line to pass the test in the function above
8 changes: 6 additions & 2 deletions Sprint-3/2-practice-tdd/count.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
function countChar(stringOfCharacters, findCharacter) {
return 5
}
return stringOfCharacters.split(findCharacter).length - 1;
}

module.exports = countChar;
console.log(countChar('hello', 'l'));
console.log(countChar('hello', 'z'));
console.log(countChar('alaaaaa', 'a'));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the PR clean and focused. Could you please remove all console logs from your PR?

11 changes: 10 additions & 1 deletion Sprint-3/2-practice-tdd/count.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
const countChar = require("./count");
// Given a string str and a single character char to search for,
// When the countChar function is called with these inputs,
// Then it should:
// Then it should: correctly count the occurrences of char in str.


// Scenario: Multiple Occurrences
// Given the input string str,
Expand All @@ -17,8 +18,16 @@ test("should count multiple occurrences of a character", () => {
expect(count).toEqual(5);
});


// Scenario: No Occurrences
// Given the input string str,
// And a character char that does not exist within the case-sensitive str,
// When the function is called with these inputs,
// Then it should return 0, indicating that no occurrences of the char were found in the case-sensitive str.

test("should return 0 for no occurrences", () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is good but it doesn't test different possible function inputs. What if the inputs' types are not strings, the char string is longer than the str string, or you have an empty string for either of the inputs, etc.? Testing different inputs will show whether your function accounts for different scenarios, which is what makes a function robust.

const str = "hello";
const char = "z";
const count = countChar(str, char);
expect(count).toEqual(0);
});
20 changes: 19 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,23 @@
function getOrdinalNumber(num) {
return "1st";
num = num.toString();
if (num.slice(-2) === '11' || num.slice(-2) === '12' || num.slice(-2) === '13') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there way not to repeat num.slice(-1) and num.slice(-2)?

return num + 'th';
} else if (num.slice(-1) === '1') {
return num + 'st';
} else if (num.slice(-1) === '2') {
return num + 'nd';
} else if (num.slice(-1) === '3') {
return num + 'rd';
} else {
return num + 'th';
}
}

module.exports = getOrdinalNumber;
console.log(getOrdinalNumber(1));
console.log(getOrdinalNumber(2));
console.log(getOrdinalNumber(3));
console.log(getOrdinalNumber(4));
console.log(getOrdinalNumber(11));
console.log(getOrdinalNumber(22));
console.log(getOrdinalNumber(33));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please let's remove these and all other console logs. These should be for your usage only and they should be deleted before pushing changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, i did that. it was on my mind but i forgot to remove them before push it

47 changes: 47 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 @@ -11,3 +11,50 @@ const getOrdinalNumber = require("./get-ordinal-number");
test("should return '1st' for 1", () => {
expect(getOrdinalNumber(1)).toEqual("1st");
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like these test cases but again, what are other expected/unexpected inputs your function can receive and how will it behave? For example, what if num is undefined, a boolean, etc.? That's just two examples of num being not of a type you expect.

// Case 2: Identify the ordinal number for 2
// When the number is 2,
// Then the function should return "2nd"

test("should return '2nd' for 2", () => {
expect(getOrdinalNumber(2)).toEqual("2nd");
});

// Case 3: Identify the ordinal number for 3
// When the number is 3,
// Then the function should return "3rd"

test("should return '3rd' for 3", () => {
expect(getOrdinalNumber(3)).toEqual("3rd");
});

// Case 4: Identify the ordinal number for 4
// When the number is 4,
// Then the function should return "4th"

test("should return '4th' for 4", () => {
expect(getOrdinalNumber(4)).toEqual("4th");
});

// Case 5: Identify the ordinal number for 11
// When the number is 11,
// Then the function should return "11th"

test("should return '11th' for 11", () => {
expect(getOrdinalNumber(11)).toEqual("11th");
});

// Case 6: Identify the ordinal number for 22
// When the number is 22,
// Then the function should return "22nd"

test("should return '22nd' for 22", () => {
expect(getOrdinalNumber(22)).toEqual("22nd");
});
// Case 7: Identify the ordinal number for 33
// When the number is 33,
// Then the function should return "33rd"

test("should return '33rd' for 33", () => {
expect(getOrdinalNumber(33)).toEqual("33rd");
});
14 changes: 13 additions & 1 deletion Sprint-3/2-practice-tdd/repeat.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
function repeat() {
return "hellohellohello";
const str = arguments[0];
const count = arguments[1];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is the right way of getting values of function arguments?

if (count < 0) {
throw new Error("Count must be a non-negative integer");
}
let result = "";
for (let i = 0; i < count; i++) {
result += str;
}
return result;
}


module.exports = repeat;
console.log(repeat("hello", 3));

25 changes: 21 additions & 4 deletions Sprint-3/2-practice-tdd/repeat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const repeat = require("./repeat");
// Given a target string str and a positive integer count,
// When the repeat function is called with these inputs,
// Then it should:
// Then it should: repeat the str count times and return a new string containing the repeated str values.

// case: repeat String:
// Given a target string str and a positive integer count,
Expand All @@ -11,22 +11,39 @@ const repeat = require("./repeat");

test("should repeat the string count times", () => {
const str = "hello";
const count = 3;
const count = 4;
const repeatedStr = repeat(str, count);
expect(repeatedStr).toEqual("hellohellohello");
expect(repeatedStr).toEqual("hellohellohellohello");
});

// case: handle Count of 1:
// Given a target string str and a count equal to 1,
// When the repeat function is called with these inputs,
// Then it should return the original str without repetition, ensuring that a count of 1 results in no repetition.

test("should return the original string when count is 1", () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test suit are more comprehensive but can you think of other test cases?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jennethydyrova i have fixed all the errors that you have mentioned to me.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried running the tests you wrote?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you try to run your unit tests, you will see that some of them are failing both for this function and getOrdinalNumber. Can you try to fix tests/functions by reading output produced when you run tests?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have and it passed all the tests.

Copy link

@jennethydyrova jennethydyrova Oct 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unit tests in your screenshots do not match those in the PR. Take a look at Sprint-3/2-practice-tdd/get-ordinal-number.test.js file, for example. Your last test in this PR is

test("should handle decimal numbers", () => {
  expect(getOrdinalNumber(21.5)).toEqual("21.5th");
});

and on the screenshot you sent the last test is

test("should return '33rd' for 33", () => {
  expect(getOrdinalNumber(33)).toEqual("33rd");
});

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jennethydyrova,
I have edited this code if you could check down

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please always double check if you pushed your local changes, deleted all scratch work (including console logs) and ran all unit tests before requesting another round of review. It will reduce time I spend on reviewing your code and you going back to the same PR over and over again. File changes tab is quite useful for checking if you code is up to standard.

I don't see any new changes. I assume you made some local changes but you haven't pushed them.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jennethydyrova, I am sorry and I appreciate your time. But I am so confused too I make the changes, do push as usual and in here every thing appears.

Alaa pic

Like this pic here it shows that the changes has been push and I do not see any unstage files.

Thanks for you patient with me

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries. Okay, I can see these changes and I can see from the function implementation, that this particular unit test on the screenshot you sent will fail but you can understand this by just running unit tests. You have these changes locally, right? If you have same changes locally and you run unit tests, some of them will fail in Sprint-3/2-practice-tdd folder indicating that some more work needs to be done.

const str = "hello";
const count = 1;
const repeatedStr = repeat(str, count);
expect(repeatedStr).toEqual("hello");
});
// case: Handle Count of 0:
// Given a target string str and a count equal to 0,
// When the repeat function is called with these inputs,
// Then it should return an empty string, ensuring that a count of 0 results in an empty output.

test("should return an empty string when count is 0", () => {
const str = "hello";
const count = 0;
const repeatedStr = repeat(str, count);
expect(repeatedStr).toEqual("");
});
// case: Negative Count:
// Given a target string str and a negative integer count,
// When the repeat function is called with these inputs,
// Then it should throw an error or return an appropriate error message, as negative counts are not valid.
// Then it should throw an error or return an appropriate error message,as negative counts are not valid.
test("should throw an error when count is negative", () => {
const str = "hello";
const count = -2;
expect(() => repeat(str, count)).toThrow("Count must be a non-negative integer");
});