Skip to content

ITP-JAN-25 | London | Ihor Bolzhelarskyi | Module-Structuring-and-Testing-Data |Sprint 2| Week 4#274

Closed
IhorBolzhelarskyi wants to merge 8 commits intoCodeYourFuture:mainfrom
IhorBolzhelarskyi:coursework/sprint-2
Closed

ITP-JAN-25 | London | Ihor Bolzhelarskyi | Module-Structuring-and-Testing-Data |Sprint 2| Week 4#274
IhorBolzhelarskyi wants to merge 8 commits intoCodeYourFuture:mainfrom
IhorBolzhelarskyi:coursework/sprint-2

Conversation

@IhorBolzhelarskyi
Copy link

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

@IhorBolzhelarskyi IhorBolzhelarskyi added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 11, 2025
@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 Feb 19, 2025
Copy link
Member

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

This is generally looking really good, congrats!

Please do updated the code with the suggestions I've made and re-add the "Needs Review" label :)

// =============> write your new code here

function capitalise(str) {
let string = `${str[0].toUpperCase()}${str.slice(1)}`;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's super clear what the difference is between a variable named str and a variable named string.

Can you think of how we could make it more clear what the difference is between these variables?

Copy link
Author

Choose a reason for hiding this comment

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

The variable str is a parameter of function capitalise(str) (input of this function). It holds a original string passed into the function. The variable string is lacal variable in this function, that stores modified version of parameter str, wich we are going to return (output of this function).

Copy link
Member

Choose a reason for hiding this comment

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

I can work that out by reading the function, but I don't think it's very clear at a glance.

Imagine if this function was much longer, and you used string at some point inside it - would it be obvious whether it was the original string or the fixed string?

In general if you have two similar variables, I'd recommend changing both of their names to make clear what each one is.

Copy link
Author

Choose a reason for hiding this comment

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

Yes,i got this, their names are almost the same
Thank you

Copy link
Member

Choose a reason for hiding this comment

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

Can you rename them to be more clear? :)

Copy link
Author

Choose a reason for hiding this comment

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

Yes😅

@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 Feb 19, 2025
@IhorBolzhelarskyi IhorBolzhelarskyi added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 19, 2025
@illicitonion illicitonion removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 20, 2025

if (hours === 0) {
hours = 12;
} else if (hours > 12) hours = hours - 12;
Copy link
Member

Choose a reason for hiding this comment

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

I'd recommend always using {}s around the body of if/else statements. As well as consistency (which is good), you can read more about some of the problems not using {}s causes at https://www.blackduck.com/blog/understanding-apple-goto-fail-vulnerability-2.html

// =============> write your new code here

function capitalise(str) {
let string = `${str[0].toUpperCase()}${str.slice(1)}`;
Copy link
Member

Choose a reason for hiding this comment

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

Can you rename them to be more clear? :)

function capitalise(str) {
let string = `${str[0].toUpperCase()}${str.slice(1)}`;
return string;
let modifiedStr = `${str[0].toUpperCase()}${str.slice(1)}`;
Copy link
Member

Choose a reason for hiding this comment

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

I'd generally recommend updating both variables - originalStr and modifiedStr - otherwise if someone just sees str they may still have the question "is this the old one or the new one" :)

Copy link
Author

Choose a reason for hiding this comment

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

yes, that makes sense, thank you

@IhorBolzhelarskyi IhorBolzhelarskyi added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 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 Feb 21, 2025
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. 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