Skip to content

Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 2 | Module Structuing and Testing Data#1186

Open
mshayriyesaricicek wants to merge 14 commits intoCodeYourFuture:mainfrom
mshayriyesaricicek:Sprint-2
Open

Sheffield | ITP-Jan-26 | Hayriye Saricicek | Sprint 2 | Module Structuing and Testing Data#1186
mshayriyesaricicek wants to merge 14 commits intoCodeYourFuture:mainfrom
mshayriyesaricicek:Sprint-2

Conversation

@mshayriyesaricicek
Copy link

@mshayriyesaricicek mshayriyesaricicek commented Mar 5, 2026

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

Coding for Sprint 2

@mshayriyesaricicek mshayriyesaricicek added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 5, 2026
@mshayriyesaricicek mshayriyesaricicek added the 📅 Sprint 2 Assigned during Sprint 2 of this module label Mar 5, 2026
// return the BMI of someone based off their weight and height
} No newline at end of file
const bmi = weight / (height * height); //calculation to calculate BMI
return bmi.toFixed(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

What type of value do you expect your function to return? A number or a string?
Does your function return the type of value you expect?

Different types of values may appear identical in the console output, but they are represented and treated differently in the program. For example,

  console.log(123);              // Output 123
  console.log("123");            // Output 123
  
  // Treated differently in the program
  let sum1 = 123 + 100;         // Evaluate to 223 -- a number
  let sum 2 = "123" + 100;      // Evaluate to "123100" -- a string.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for pointing this out. I have researched this now and understand that the answer would have been a number if I hadn't requested it to be to 1 decimal place. The tofixed(1) converts the number to a string. In this case it doesn't effect the outcome of the answer printed but I now understand that if I did need to do calculations on the answer then it would need to be converted back to a number in order to do this so it is good practice to convert back to a number.

I have amended the program to convert the string answer back to a number and print a number.

I know as good practice there are usually inbuilt checks in case people input incorrect data. If you want me to do this I can.

Copy link
Contributor

Choose a reason for hiding this comment

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

As long as you are aware of the type of the data you are returning, its is enough.

The spec was not clear on this anyway, and returning the result as a number as its shorting coming too.

Comment on lines +8 to +24
function getPenceString(penceString){

const penceStringWithoutTrailingP = penceString.substring(0,penceString.length - 1);
//removes p
const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
//puts zeros in front of number if less than 3 digits
const pounds = paddedPenceNumberString.substring(0,paddedPenceNumberString.length - 2);
//removes last 2 digits to get pounds
const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0");
//gets last 2 digits to get pence, if less than 2 digits adds zeros to end of string but shouldnt be less than 3
//due to padStart above
return `£${pounds}.${pence}`;
// returns string with pounds and pence in correct format
}

console.log(getPenceString("399p"));
// tested with 123p 1200p 24589p 89p 9p and 0p
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation is off.

Have you installed prettier VSCode extension and enabled formatting on save/paste on VSCode
as recommended in
https://github.com/CodeYourFuture/Module-Structuring-and-Testing-Data/blob/main/readme.md
?

Copy link
Author

Choose a reason for hiding this comment

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

I did install prettier and enabled formatting on save/paste. I may have done it after I had done this or it may not be working.

Copy link
Contributor

Choose a reason for hiding this comment

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

Understood.

I cannot keep track of whom I had reminded of this. So I just nagged the person with this reminder whenever I spotted improperly formatted code.

@cjyuan cjyuan 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 6, 2026
@mshayriyesaricicek mshayriyesaricicek added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 7, 2026
@cjyuan
Copy link
Contributor

cjyuan commented Mar 7, 2026

All good! Well done!

@cjyuan cjyuan added 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 Mar 7, 2026
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. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants