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.

Comment on lines +20 to +27
return str.toUpperCase().split('').map(function(c) {
// splits string into individual characters and maps each character to a new value

return /[A-Z0-9]/.test(c) ? c : '_';
// checks if the character is an uppercase letter or a digit

}).join('');
// joins the array of characters back into a single string and replaces spaces with underscores
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment on line 27 and the code on lines 20-26 do not quite match because
space characters are not the only characters that will get replaced by _ in your implementation.

We can also use .replace() or .replaceAll() to achieve to same outcome -- less code to write.

Copy link
Author

Choose a reason for hiding this comment

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

I have changed line 27 to show that it replacds special characters as well as spaces with underscore.

I have researched .replace() and .replaceAll() and see that this works on the whole string at once so wouldn't need to split the string then join it again. Thank you for the advice.

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.

@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
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. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants