-
-
Notifications
You must be signed in to change notification settings - Fork 218
LONDON | MAY_25 | EMILIANO URUENA | SPRINT3 #595
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
LONDON | MAY_25 | EMILIANO URUENA | SPRINT3 #595
Conversation
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 Emiliano, hope you are well.
Thanks for submitting this work for sprint 3, please see the attached comments.
// Write the code to pass the test | ||
// Then, write the next test! :) Go through this process until all the cases are implemented | ||
|
||
function getAngleType(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.
I can see that there is an implementation of getAngleType
in 2-mandatory-rewrite/1-get-angle-type.js
.
Perhaps it would also be good to copy that to this file?
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.
You're right! I just did it.
// When the angle is less than 90 degrees, | ||
// Then the function should return "Acute angle" | ||
const acute = getAngleType(45); | ||
assertEquals(acute, "Acute 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.
Just curious if you got this assertion statement to work?
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.
It is working now.
// ====> complete with your assertion | ||
|
||
// Stretch: | ||
// What other scenarios could you test for? |
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.
Another test case scenario that you could cover is when the absolute numerator value is bigger than the denominator?
Example
Numerator: -5 Denominator: 3
Numerator: -7 Denominator: 2
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.
That's a good point, I added to the next lines.
if (angle < 90) return "Acute angle"; | ||
if (angle >90 && angle < 180) return "Obtuse angle"; | ||
if (angle === 180) return "Straight angle"; | ||
if (angle > 180) return "Reflex 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.
Stretch: Is the check for angle > 90
required given the two checks on line 2 & 3?
What about when the inputted angle is 361
?
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.
Hi.. I've added the line 2 for angles upper 360 degrees.
Is requiered the check for angle between 90 and 180 degrees.
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 just added in case of invalid values like 361.
90 is necesary to check values between 90 and 180.
@@ -0,0 +1,20 @@ | |||
function getAngleType(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.
This function looks 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.
Thank you Sr.
test("(sum less than 16)", () => {expect(cardValidator(1111111111111110)).toEqual(false);}); | ||
test("(odd final number)", () => {expect(cardValidator(6666666666666661)).toEqual(false);}); | ||
test("valid number '9999777788880000' ", () => {expect(cardValidator(9999777788880000)).toEqual(true);}); | ||
test("valid number '6666666666661666' ", () => {expect(cardValidator(6666666666661666)).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.
Glad to see that this works for the test cases outlined.
function cardValidator(numCard){ | ||
let validCard = true; | ||
//- Number must be 16 digits, all of them must be numbers. | ||
validCard = validCard && (numCard.toString().length === 16); |
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.
Perhaps checks for each condition could be cleaner using if
statements.
if (numCard.toString().length !== 16) {
return 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.
I totally agree.
@@ -0,0 +1,32 @@ | |||
function cardValidator(numCard){ |
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.
The type of this argument is ambiguous, from the test cases it looks as if it could be a string or 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.
In this excerise, I tried to use ValidCard as a boolean general value, and reassign boolean values according to the statements. At the end it works, but I completely agree: it is more complicated and less crear.
Num = numCard.toString()[i]; | ||
}else if ((Num !== numCard.toString()[i])){ | ||
sameNum = false; | ||
i = numCard.toString().length; |
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 is one way to check if numCard
has the same character throughout.
If the last character is different from the current character being looked at then terminate the loop.
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.
Well I didn’t think that, it would be easier.
//- The sum of all the digits must be greater than 16. | ||
let sumDigits = 0; | ||
for (let i = 0 ; i < numCard.toString().length; i++){ | ||
sumDigits = sumDigits + numCard.toString().slice(i,i+1)*1; |
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.
What was the reason behind multiplying by 1?
Perhaps we can have a discussion about this one in person?
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 was to convert the string to number without using the Number() method.
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.
The changes were done. Thank you for the feedback.
if (angle < 90) return "Acute angle"; | ||
if (angle >90 && angle < 180) return "Obtuse angle"; | ||
if (angle === 180) return "Straight angle"; | ||
if (angle > 180) return "Reflex 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.
Hi.. I've added the line 2 for angles upper 360 degrees.
Is requiered the check for angle between 90 and 180 degrees.
// Write the code to pass the test | ||
// Then, write the next test! :) Go through this process until all the cases are implemented | ||
|
||
function getAngleType(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.
You're right! I just did it.
// When the angle is less than 90 degrees, | ||
// Then the function should return "Acute angle" | ||
const acute = getAngleType(45); | ||
assertEquals(acute, "Acute 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.
It is working now.
// ====> complete with your assertion | ||
|
||
// Stretch: | ||
// What other scenarios could you test for? |
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.
That's a good point, I added to the next lines.
if (angle < 90) return "Acute angle"; | ||
if (angle >90 && angle < 180) return "Obtuse angle"; | ||
if (angle === 180) return "Straight angle"; | ||
if (angle > 180) return "Reflex 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.
I just added in case of invalid values like 361.
90 is necesary to check values between 90 and 180.
const count = -1; | ||
const repeatedStr = repeat(str, count); | ||
expect(repeatedStr).toEqual("Negative counts are not valid."); | ||
}); |
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 Sr.
//- The sum of all the digits must be greater than 16. | ||
let sumDigits = 0; | ||
for (let i = 0 ; i < numCard.toString().length; i++){ | ||
sumDigits = sumDigits + numCard.toString().slice(i,i+1)*1; |
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 was to convert the string to number without using the Number() method.
@@ -0,0 +1,32 @@ | |||
function cardValidator(numCard){ |
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 this excerise, I tried to use ValidCard as a boolean general value, and reassign boolean values according to the statements. At the end it works, but I completely agree: it is more complicated and less crear.
function cardValidator(numCard){ | ||
let validCard = true; | ||
//- Number must be 16 digits, all of them must be numbers. | ||
validCard = validCard && (numCard.toString().length === 16); |
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 totally agree.
Num = numCard.toString()[i]; | ||
}else if ((Num !== numCard.toString()[i])){ | ||
sameNum = false; | ||
i = numCard.toString().length; |
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.
Well I didn’t think that, it would be easier.
Self checklist
Changelist
Sprint 3 - Module Structuring and Testing Data
COMMITS: