Skip to content

London | 26-ITP-January | Khaliun Baatarkhuu | Sprint 2 | Coursework. #1143

Open
khaliun-dev wants to merge 10 commits intoCodeYourFuture:mainfrom
khaliun-dev:coursework/sprint-2
Open

London | 26-ITP-January | Khaliun Baatarkhuu | Sprint 2 | Coursework. #1143
khaliun-dev wants to merge 10 commits intoCodeYourFuture:mainfrom
khaliun-dev:coursework/sprint-2

Conversation

@khaliun-dev
Copy link

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

  • Completed all mandatory debugging exercises
  • Fixed logical errors in existing functions
  • Tested all exercises to confirm expected behavior

Questions

None at the moment.

Updated variable name to avoid redeclaration error.
Removed redeclaration of decimalNumber and updated console.log to call the function.
Corrected the square function to use a valid parameter name and return the square of the input.
…g the result.

Changed console.log to return in multiply function to fix undefined error.
Corrected the sum function to return the sum of two numbers instead of undefined.
Updated the getLastDigit function to accept a parameter and removed unused variable.
Implement BMI calculation and log result.
Add function to convert string to upper snake case
…ock of code.

Implemented the toPounds function to convert pence to pounds.
@khaliun-dev khaliun-dev added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 3, 2026

// =============> write your explanation here
// =============> write your new code here
//Above code works because we have used another variable "newStr", avoiding redeclaration.
Copy link

@ykamal ykamal Mar 3, 2026

Choose a reason for hiding this comment

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

This is good. But do you think there could be another way to do this? One that doesn't require you to declare any variables at all?

Copy link
Author

Choose a reason for hiding this comment

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

function capitalise(str) {
return str[0].toUpperCase() + str.slice(1);
}

Could this work? Just by removing the unnecessary variable?

Copy link

Choose a reason for hiding this comment

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

Yes. Less memory, simpler. Well done

const decimalNumber = 0.5;
const percentage = `${decimalNumber * 100}%`;

return percentage;
Copy link

Choose a reason for hiding this comment

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

This is good. But do you think there could be another way to do this? One that doesn't require you to declare any variables at all?

Copy link
Author

Choose a reason for hiding this comment

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

function convertToPercentage(decimalNumber) {
return ${decimalNumber * 100}%;
}

console.log(convertToPercentage(0.5));

Copy link

Choose a reason for hiding this comment

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

Yes similar to before

Copy link

Choose a reason for hiding this comment

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

Make sure to retain the string templating


function calculateBMI(weight, height) {
function calculateBMI(weight, height) {
const bmi = weight / (height * height);
Copy link

Choose a reason for hiding this comment

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

There's a division here. Do you think we need to put in any specific safety guards?

Copy link
Author

Choose a reason for hiding this comment

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

We should guard against height being 0 so we could add the following guard:

if (height <= 0) {
return "Height must be greater than 0";
}

Copy link
Author

Choose a reason for hiding this comment

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

@ykamal I think i have fixed all three problems you have raised, could you please have another look?

Copy link

Choose a reason for hiding this comment

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

Less than 0 is still fine. It's 0 that's the problem.

Copy link
Author

Choose a reason for hiding this comment

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

function calculateBMI(weight, height) {
if (height === 0) {
throw new Error("Height cannot be 0");
}

const bmi = weight / (height * height);
return Number(bmi.toFixed(1));

}

@ykamal i have changed the guards for 0 specifically

Copy link

Choose a reason for hiding this comment

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

Great, thanks. Ah, it's a body weight thing, so less than zero would be a problem 😂😂 but code wise this is fine

@kfklein15 kfklein15 requested a review from ykamal March 9, 2026 17:51
Copy link

@ykamal ykamal left a comment

Choose a reason for hiding this comment

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

After the division change, it should be good

Copy link

@ykamal ykamal left a comment

Choose a reason for hiding this comment

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

LGTM, approved

@ykamal ykamal 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 Mar 10, 2026
@khaliun-dev
Copy link
Author

@ykamal thanks for approving my PR, could you add the completed tag, please?

@ykamal ykamal added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 11, 2026
@ykamal
Copy link

ykamal commented Mar 11, 2026

@ykamal thanks for approving my PR, could you add the completed tag, please?

Done. Hopefully I've done it right. Nice work

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants