Skip to content

Brussels | ITP-2026-1 | Benjamin Vanderzeypen | Sprint 3 | Coursework/sprint 3#66

Closed
nuttyproducer wants to merge 3 commits intoHackYourFutureBelgium:mainfrom
nuttyproducer:coursework/sprint-3-implement-and-rewrite
Closed

Brussels | ITP-2026-1 | Benjamin Vanderzeypen | Sprint 3 | Coursework/sprint 3#66
nuttyproducer wants to merge 3 commits intoHackYourFutureBelgium:mainfrom
nuttyproducer:coursework/sprint-3-implement-and-rewrite

Conversation

@nuttyproducer
Copy link
Copy Markdown

Changelist

We've created tests with assertEquals and with a testing environment named Jest.
Tests all run succesfull.

Questions

I've read that we can leave out the last "else" in a function.
For example:

  } else if (rank === "2") {
    return 2;
  } else {
    throw new Error("Invalid card");

It means we can close the function with only trow new Error("invalid card");

I haven't tested it but I guess it would work? Is this best practice for the future?

I also had to adjust 3-get-card-value.js because we were expected to have a "real" error message -> Invalid card.
@nuttyproducer nuttyproducer marked this pull request as ready for review April 1, 2026 09:08
}
if (angle === 180) {
return "Straight angle";
} else {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

here, you could get rid of the else, as it will always fall here if none of the previous choices got choosed.

// Then the function should return "Obtuse angle"
const obtuse = getAngleType(120);
// ====> write your test here, and then add a line to pass the test in the function above
assertEquals(obtuse, "Obtuse angle");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Here you see a good example of constant usage. You could have a constant for the string "Obtuse angle", so you don't have to repeat writing the string two times and get the risk a typo.

const ObstuseAngle = "Obstuse angle";

// complete the rest of the tests and cases
// write one test at a time, and make it pass, build your solution up methodically

function isProperFraction(numerator, denominator) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some of the tests are failing. Something is msising on the function

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Wow! I totally missed that! I guess I wasn't awake yet 🐙 Thanks for running the tests again on my behalve to see what was wrong!

@@ -8,8 +8,30 @@
// write one test at a time, and make it pass, build your solution up methodically
// just make one change at a time -- don't rush -- programmers are deep and careful thinkers
function getCardValue(card) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You can simplify the function considering the code below. So all the numeric values return themselves but as numbers instead of strings, so you dont need to repeat all of them.

else if (!isNaN(rank) && rank !== "") { return parseInt(rank, 10); }

assertEquals(nineofClubs, 9);

// Handles invalid cards
const invalidCard = getCardValue("Z♠");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Your function is not returning undefined when receiving an invalid parameter, but throwing an error instead. So this test assertion will never work.
You need to adjust your function in the test. As you wish.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm fixing that now, but I had to do my research to find the perfect solution for this, we can do the test with try and catch.

@robertopaixao robertopaixao added the bug Something isn't working label Apr 3, 2026
Copy link
Copy Markdown
Author

@nuttyproducer nuttyproducer left a comment

Choose a reason for hiding this comment

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

I've refactored and fixed the tests to comply with all the coursework exercises.

Thank you again for reviewing @robertopaixao !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants