Skip to content

London|MAY_2025|FATMA_DEGIRMENCI|STRUCTRING_AND_TESTING_DATA| SPRINT 3 #640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

fatmaevin
Copy link

@fatmaevin fatmaevin commented Jul 5, 2025

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

@fatmaevin fatmaevin added the Needs Review Participant to add when requesting review label Jul 5, 2025
@cjyuan cjyuan added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Participant to add when requesting review labels Jul 15, 2025
Comment on lines 2 to 13
if (angle === 90) {
return "Right angle";
} else if (angle < 90) {
return "Acute angle";
} else if (angle > 90 && angle < 180) {
return "Obtuse angle";
} else if (angle === 180) {
return "Straight angle";
} else if (angle > 180 && angle < 360) {
return "Reflex angle";
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The spec isn't clear whether angle can be assigned a number not in the interval (0, 360).
When angle is >= 360, what should the function return? (Also, by definition, angles <= 0 are not considered acute angles.)

When we implement a function that can return a value, to ensure reliability, we should ensure it will always return a defined value instead of undefined (which represents "no return value").
If the parameter, angle, is not within the recognised range, we can design the function to return a special value (e.g., "Invalid angle") or throw an error.

if (numerator < denominator) return true;
// add your completed function from key-implement here
if (denominator === 0) {
return undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Returning undefined in JS has the same meaning as "no return value".

  • We could also return false when the parameters cannot form a proper fraction. Technically, 1/0 or 0/1 are not proper fractions.

Comment on lines 3 to 4
if (Number(rank) <= 10 && Number(rank) >= 2) {
return Number(rank);
Copy link
Contributor

Choose a reason for hiding this comment

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

In JavaScript, strings that represent valid numeric literals in the language can be safely converted to equivalent numbers. For examples, "0x02", "2.1", or "00_02".

Does your function return the value you expected from each of the following function calls?

getCardValue("0x02♠");
getCardValue("2.1♠");
getCardValue("00_02♠");

Comment on lines 3 to 5
test("should return 4 for 4 of Hearts", () => {
expect(getCardValue("4♠")).toEqual(4);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

When preparing tests, we should ensure the tests cover all possible cases. If we specify a test for individual card, we will need about 53 tests to cover all possible cases. Instead, we could consider classifying all possible values into different categories, and then within each category we test some samples.

For example, one possible category for getCardValue() is, "should return the value of number cards (2-10)", and we can prepare the test as

test("should return the value of number cards (2-10)", () => {
    expect(getCardValue("2♣︎")).toEqual(2);
    expect(getCardValue("5♠")).toEqual(5);
    expect(getCardValue("10♥")).toEqual(5);
    // Note: We could also use a loop to check all values from 2 to 10.
});

Comment on lines 7 to 9
test("should return 10 for Queen of Spades", () => {
expect(getCardValue("Q♠")).toEqual(10);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

We could generalise this test to "should return 10 for face cards (J, Q, K)" and check all three ranks J, Q, K.

Comment on lines 2 to 12
if (n > 3 && n < 21) return n + "th";
switch (n % 10) {
case 1:
return n + "st";
case 2:
return n + "nd";
case 3:
return n + "rd";
default:
return n + "th";
}
Copy link
Contributor

Choose a reason for hiding this comment

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

getOrdinalNumber(511) should return "511th".
Consider looking up the rules to clarify how ordinal numbers are formed.

Comment on lines 14 to 16
test("should return '2nd' for 2", () => {
expect(getOrdinalNumber(2)).toEqual("2nd");
});
Copy link
Contributor

Choose a reason for hiding this comment

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

To ensure thorough testing, we need broad scenario coverage. Listing individual values, however, can quickly lead to an unmanageable number of test cases.
Instead of writing tests for individual numbers, consider grouping all possible input values into meaningful categories. Then, select representative samples from each category to test. This approach improves coverage and makes our tests easier to maintain.

For example, we can prepare a test for numbers 2, 22, 132, etc. as

test("append 'nd' to numbers ending in 2, except those ending in 12", () => {
    expect( getOrdinalNumber(2) ).toEqual("2nd");
    expect( getOrdinalNumber(22) ).toEqual("22nd");
    expect( getOrdinalNumber(132) ).toEqual("132nd");
});

Can you update the tests in this script so that they can cover all valid integers?

Comment on lines 1 to 2
function isValidPassword(password) {
const previousPasswords = ["abcD1*", "Fatma123.", "App23$"];
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Avoid using invalid passwords as one of previous passwords.

  • Could also consider accepting previousPasswords array through the 2nd parameter so that the callers have the flexibility to specify previous passwords.

Copy link
Contributor

Choose a reason for hiding this comment

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

The tests in this script should also check if the function can return false when the password satisfies all other conditions except the one described in the test.

For example,

test("password has at least 5 characters", () => {
    // This password contains each of the required characters but is too short
    expect( isValidPassword("Aa1$") ).toEqual(false);
}

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jul 15, 2025
@fatmaevin fatmaevin added the Needs Review Participant to add when requesting review label Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review Participant to add when requesting review Reviewed Volunteer to add when completing a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants