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?

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


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?

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

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants