Skip to content

Conversation

Emilianouz
Copy link

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

Sprint 3 - Module Structuring and Testing Data
COMMITS:

  1. Key implemented MSTD Sprint-3
  2. Mandatory Rewrite MSTD Sprint-3
  3. Mandatory Practice / Implement MSTD Sprint-3
  4. Stretch Investigate MSTD Sprint-3 Credit card validator

@Emilianouz Emilianouz added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 3 Assigned during Sprint 3 of this module labels Jun 23, 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 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) {

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?

Copy link
Author

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");

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?

Copy link
Author

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?

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

Copy link
Author

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";

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?

Copy link
Author

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.

Copy link
Author

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) {

Choose a reason for hiding this comment

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

This function looks good

Copy link
Author

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);});

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);

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;
}

Copy link
Author

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){

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?

Copy link
Author

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;

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.

Copy link
Author

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;

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?

Copy link
Author

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.

@Amundeep-Dhaliwal Amundeep-Dhaliwal added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 9, 2025
Copy link
Author

@Emilianouz Emilianouz left a 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";
Copy link
Author

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) {
Copy link
Author

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");
Copy link
Author

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?
Copy link
Author

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";
Copy link
Author

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.");
});
Copy link
Author

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;
Copy link
Author

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){
Copy link
Author

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);
Copy link
Author

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;
Copy link
Author

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.

@Emilianouz Emilianouz added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Jul 11, 2025
@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 14, 2025
@illicitonion illicitonion changed the title LONDON | MAY_25 | EMILIANO URUENA | MSTD_SPRINT3 LONDON | MAY_25 | EMILIANO URUENA | SPRINT3 Jul 15, 2025
@illicitonion illicitonion deleted the branch CodeYourFuture:to-be-deleted-coursework/sprint-3 July 21, 2025 09:46
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. 📅 Sprint 3 Assigned during Sprint 3 of this module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants