Skip to content

Conversation

@Alaa-Tagi
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

I have created a PR with completed tasks as required.

Questions

No questions

@Alaa-Tagi Alaa-Tagi added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Structuring-And-Testing-Data The name of the module. labels Oct 12, 2025
@jennethydyrova jennethydyrova added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 23, 2025
Copy link
Contributor

@jennethydyrova jennethydyrova left a comment

Choose a reason for hiding this comment

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

Hi @Alaa-Tagi! Great job on translating instructions into functions. It was quite easy to read your PR, which is always a good thing for a reviewer!

A couple of things to note:

  1. You should try to remove all your testing and scratch work when pushing a PR (mostly console logs in your case).
  2. Test cases need to be more comprehensive. Think of it this way: when you write different test cases for your functions, you help yourself catch bugs early. For example, currently your getOrdinalNumber function will most likely return "trueth" for num=true, which I don't think is the expected behavior.

Comment on lines 6 to 9
console.log(countChar('hello', 'l'));
console.log(countChar('hello', 'z'));
console.log(countChar('alaaaaa', 'a'));

Copy link
Contributor

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?

// 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", () => {
Copy link
Contributor

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.

function getOrdinalNumber(num) {
return "1st";
num = num.toString();
if (num.slice(-2) === '11' || num.slice(-2) === '12' || num.slice(-2) === '13') {
Copy link
Contributor

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)?

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

Copy link
Contributor

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.

Comment on lines 2 to 3
const str = arguments[0];
const count = arguments[1];
Copy link
Contributor

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?

// 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", () => {
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor

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
Contributor

@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

Copy link
Contributor

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

Copy link
Contributor

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.

@jennethydyrova jennethydyrova added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Oct 23, 2025
@Alaa-Tagi Alaa-Tagi added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 24, 2025
Comment on lines +76 to +90
// Scenario: char string longer than str string
test("should return 0 when char is longer than the input string", () => {
const str = "a";
const char = "abc";
const count = countChar(str, char);
expect(count).toEqual(0);
});

// Scenario: Non-string inputs
test("should return 0 when inputs are not strings", () => {
expect(countChar(12345, "1")).toEqual(0);
expect(countChar("12345", 1)).toEqual(0);
expect(countChar(null, "a")).toEqual(0);
expect(countChar("hello", undefined)).toEqual(0);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine but when you read this function's purpose, you might think that if char is longer than str, it should perhaps throw an error as there is no way to count char occurrence in this case. It's fine to leave Scenario: char string longer than str string test case as is but it's something to consider while designing your function.

Same for Scenario: Non-string inputs but this test case should definitely throw errors.

});

// Scenario: Case sensitivity
test("should count only exact case matches", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Very thoughtful test case!

Comment on lines 20 to 26
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));
Copy link
Contributor

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

Comment on lines 79 to 83
test("should handle undefined inputs gracefully", () => {
expect(() => repeat(undefined, 3)).toThrow();
expect(() => repeat("hello")).toThrow();
expect(() => repeat()).toThrow();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't look correct to me. Your function doesn't throw any errors in the cases you wrote here.

Copy link
Author

Choose a reason for hiding this comment

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

i fixed the code

Copy link
Author

Choose a reason for hiding this comment

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

@jennethydyrova , Here the new code ( Editied )

Copy link
Contributor

@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.

Your tests are still failing. These are all tests in Sprint-3/2-practice-tdd folder . Also, you have some error in one of the files.

Screenshot 2025-10-26 at 23 07 30

@jennethydyrova jennethydyrova added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 26, 2025
@Alaa-Tagi Alaa-Tagi added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 26, 2025
@jennethydyrova jennethydyrova added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 26, 2025
@Alaa-Tagi Alaa-Tagi added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 26, 2025
@jennethydyrova jennethydyrova added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 26, 2025
@Alaa-Tagi
Copy link
Author

i have editing both get ordinal and repeat code . also i have tried both tests with different laptop it showed failed but in my laptop showed passed i dont know why but i will figure it out later. so, i editing the two codes and tried to run them on another laptop it show passed to all test after editing .

@jennethydyrova
Copy link
Contributor

Looks good to me, good job! Regarding not having same code on both computers, double check if you pull all changes from branch. If you work on one laptop and then continue on another one, your changes will not be automatically pulled.

@jennethydyrova jennethydyrova added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Structuring-And-Testing-Data The name of the module. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants