-
-
Notifications
You must be signed in to change notification settings - Fork 218
LONDON | ITP-MAY-25 | TEWODROS BEKERE | Coursework/sprint-3 #602
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
Conversation
…-3\4\card-validator.js
There was a problem hiding this 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) |
There was a problem hiding this comment.
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"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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. |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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;'
There was a problem hiding this comment.
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♠"); |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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; | ||
} |
There was a problem hiding this comment.
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 (++). |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
// 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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (previousPasswords.includes(password)) return false; | ||
|
||
// If all checks pass, the password is valid | ||
return true; |
There was a problem hiding this comment.
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); | ||
}); |
There was a problem hiding this comment.
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.
@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. |
Thanks for the updates & screenshots Tewodros. |
Learners, PR Template
Self checklist
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.