Skip to content

London | May-2026-itp | Vitalii Kmit | Sprint 3 | Implement and rewrite tests#1463

Open
Vitalii-code wants to merge 1 commit into
CodeYourFuture:mainfrom
Vitalii-code:implement-tests
Open

London | May-2026-itp | Vitalii Kmit | Sprint 3 | Implement and rewrite tests#1463
Vitalii-code wants to merge 1 commit into
CodeYourFuture:mainfrom
Vitalii-code:implement-tests

Conversation

@Vitalii-code

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

In this PR I worked on adding tests with plain javascript and then with jest

@Vitalii-code Vitalii-code added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 5, 2026
@illicitonion illicitonion added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 8, 2026

@illicitonion illicitonion left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This generally looks good, but I left a few comments to look at :) Thanks!

// TODO: Implement this function
if (angle > 0 && angle < 90) {
return "Acute angle";
} else if (angle == 90) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Here you're using == but JavaScript also has a === operator. Do you know the difference? Why have you chosen to use == here? When would === make more sense?

This applies in many places in your PR - please take a look at them all!

return "Right angle";
} else if (angle > 90 && angle < 180) {
return "Obtuse angle";
} else if (angle == 180) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same as above


function getCardValue(card) {
// TODO: Implement this function
const lastChar = card.length - 1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The name of this variable suggests it contains a character. But it actually contains an index of a character. Can you think of a name that could make this more clear?

}

if (!(suit === "♠" || suit === "♥" || suit === "♦" || suit === "♣")) {
throw new Error("Invalid suit ", suit);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's often useful to include in an error message what the invalid data was. Imagine you're are running a big long programme, and aren't sure exactly what data is being processed - the more context we can give in errors the better.

const rank = card.slice(0, lastChar);
const suit = card.slice(lastChar);

if (rank === "10") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This works, but I'm curious - why did you decide to handle 10 specially here?

What would happen if someone passed the string "10Q" to this function? What would you want to happen? What other edge cases may you want to test for in your tests?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please revert the changes to this file, they're not relevant for this exercise.

@illicitonion illicitonion added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants