Skip to content

Conversation

iteddy16
Copy link

Learners, PR Template

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

Changelist

Fix the code for angle type, proper fraction, and get the card value by modifying the code for the testing run. Also, respond to the question raised in the comment section of each folder.

Questions

Ask any questions you have for your reviewer.

@iteddy16 iteddy16 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jun 24, 2025
Copy link

@Amundeep-Dhaliwal Amundeep-Dhaliwal left a comment

Choose a reason for hiding this comment

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

Hello Tewodros, hope you are well.

Thanks for submitting this work, please see the comments.

if (angle > 180 && angle < 360) return "Reflex Angle";
if( angle < 0 || angle > 360)
return "Invalid Angle"; // This handles angles outside the 0-360 range
if(angle === 0 || angle === 360)

Choose a reason for hiding this comment

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

This function looks good.

Could you use the conditional angle <= 0 || angle >= 360 to decide whether the parameter is an "Invalid Angle"?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it works for < 0 and exact 0 and >360 and exact 360 returns invalid.
code2

// If you want to handle negative fractions, you can also add a case for that.
// If you want to handle fractions where the numerator is equal to the denominator,
// you can also add a case for that.
// If you want to handle fractions that are not numbers, you can also add a case for that.

Choose a reason for hiding this comment

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

I see that you have added comments for handling edge cases for this function, seems like your requirements are well defined.

Perhaps this would be a good stretch for you to introduce logic for handling the denominator being zero.

How would you handle the situation where the numerator is -4 & the denominator is 3?

Copy link
Author

Choose a reason for hiding this comment

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

I added the zero denominator to throw an error, and for this logic (-4, 3) it's handled by ' if (numerator < denominator) return true;'

Choose a reason for hiding this comment

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

Thank you for adding that check to make sure the denominator is non-zero.

// Then it should return the numerical card value
const aceofSpades = getCardValue("A♠");
assertEquals(aceofSpades, 11);
const ace_of_Spades = getCardValue("A♠");

Choose a reason for hiding this comment

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

In Javascript it is common to use the camel case naming convention, aceOfSpades.

In python it is common to use the snake case naming convention for variables e.g. ace_of_spades.

Copy link
Author

Choose a reason for hiding this comment

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

I have updated all to the correct form.
code4

// Given a card with an invalid rank (neither a number nor a recognized face card),
// When the function is called with such a card,
// Then it should throw an error indicating "Invalid card rank."
function getCardValue(card) {

Choose a reason for hiding this comment

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

This function is implemented well.

Replacing the getCardValue function at the top of this file with this one would be good.

Copy link
Author

Choose a reason for hiding this comment

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

I replaced the above getCardValue function.

return "Obtuse angle";
} else if (angle === 180) {
return "Straight angle";
}else if (angle > 180 && angle < 360) {

Choose a reason for hiding this comment

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

This function looks good and covers the requirements. Nice job.

The two checks for angle > 90 and angle > 180 are not necessary.

Copy link
Author

Choose a reason for hiding this comment

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

I updated the function to address all the comments to look like this, and I tested it for all possible outputs, and it works.
code5

Choose a reason for hiding this comment

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

This satisfies the criteria.


// All checks passed, return true
return true;
}

Choose a reason for hiding this comment

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

This implementation looks elegant, nice to stretch your capabilities.


// a) How the index variable updates during the call to find

// The index commences at 0 and is incremented by 1 on each iteration of the loop via the use of the index operator (++).

Choose a reason for hiding this comment

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

Did you mean increment operator?

Copy link
Author

Choose a reason for hiding this comment

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

I updated with a clearer statement like this:
code8


// b) What is the if statement used to check

// The function performs a comparison of the current character in the string (str[index]) with the character specified in the search parameter.

Choose a reason for hiding this comment

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

This answer is correct, did you mean condition instead of function here?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, function is always in my mind, that's why. I updated it like this:
code9

if (previousPasswords.includes(password)) return false;

// If all checks pass, the password is valid
return true;

Choose a reason for hiding this comment

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

This looks good, you covered all the requirements for this function.

I like how you used previousPasswords as an optional parameter.

const previousPasswords = ["Test@123", "Test123!"];
const result = isValidPassword(password, previousPasswords);
expect(result).toEqual(true);
});

Choose a reason for hiding this comment

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

These tests for isValidPassword look comprehensive. Nice one.

@iteddy16
Copy link
Author

iteddy16 commented Jul 9, 2025

@Amundeep-Dhaliwal Thank you for your detailed review and comments, I addressed the point raised in the PR and also here in the comments to make it easier to look I put the screenshots.

@Amundeep-Dhaliwal
Copy link

Thanks for the updates & screenshots Tewodros.

@Amundeep-Dhaliwal Amundeep-Dhaliwal added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 11, 2025
@illicitonion illicitonion changed the base branch from to-be-deleted-coursework/sprint-3 to main July 17, 2025 14:54
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants