-
-
Notifications
You must be signed in to change notification settings - Fork 275
NW | 25-ITP_Sep | Ahmad Hmedan | Sprint 3 | implement and rewrite tests #812
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
base: main
Are you sure you want to change the base?
NW | 25-ITP_Sep | Ahmad Hmedan | Sprint 3 | implement and rewrite tests #812
Conversation
| if (numerator < 1) numerator = numerator * -1; | ||
| if (denominator < 1) denominator = Math.abs(denominator); |
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.
Why use different approaches to remove the negative sign from a number?
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 don't know if you want me to use an existing library or solve it manually.
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 real interview, developers are expected to explain their code and give a rational explanation why they do things in certain way.
Your code looks odd to me, that's why I raised the question.
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.
Thanks for your feedback. From now on, I’ll try to write my code as if I’m working.
| const convertTheStringtoNumber = Number(rank); | ||
| if (convertTheStringtoNumber >= 2 && convertTheStringtoNumber <= 10) { |
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, strings that represent valid numeric literals in the language can be safely
converted to equivalent numbers or parsed into a valid integers.
Do you want to recognize these string values as valid ranks?
To find out what these strings are, you can ask AI
What kinds of string values would make
Number(rank)evaluate to2in 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.
Thanks, I’ve learned a new validation technique from your feedback.
| test("returns true for a negative proper fraction( absolute value of the numerator is less than the denominator)", () => { | ||
| expect(isProperFraction(-4, 7)).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.
When preparing tests, we should ensure the tests cover all possible cases (and maybe test multiple samples within each case to make the test more robust). Can you think of case(s) that should also be tested?
cjyuan
left a comment
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.
Changes look good.
| if (numerator < 1) numerator = Math.abs(numerator) ; | ||
| if (denominator < 1) denominator = Math.abs(denominator); |
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.
denominator < 0 is probably more expressive in the sense that it is closer to the definition of "negative number".
| test("returns false for a negative proper fraction( absolute value of the denominator is less than the numerator)", () => { | ||
| expect(isProperFraction(-7, 4)).toEqual(false); | ||
| }); |
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.
- -7/4 is considered a negative improper fraction.
Learners, PR Template
Self checklist
Changelist
I have solved all the tasks in the coursework
Thanks in advance for reviewing my code
Questions
none,