Skip to content

Comments

London | 26-ITP-January | Eugenie Ahangama | Sprint 2 | coursework/sprint 2#931

Open
Eugenie-A wants to merge 12 commits intoCodeYourFuture:mainfrom
Eugenie-A:coursework/sprint-2
Open

London | 26-ITP-January | Eugenie Ahangama | Sprint 2 | coursework/sprint 2#931
Eugenie-A wants to merge 12 commits intoCodeYourFuture:mainfrom
Eugenie-A:coursework/sprint-2

Conversation

@Eugenie-A
Copy link

Learners, PR Template

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

I worked through the Sprint 2 exercises by going through the starter code, identifying the main errors and making sure I understood why the logic wasn't working. I then wrote tests in the debug section to clearly show the issues before fixing anything. After that, I implemented the correct JavaScript behaviour so the function produced the right results. Finally, in the interpret task, I explained what the original code was doing, why it failed and how my fixes solved those problems.

MDN References I used:
String.prototype.slice()
Number() constructor
Template literals
console.assert()
String.prototype.split()
Array.prototype.map()
Remainder operator (%)
String.prototype.padStart()
String.prototype.substring()
String.prototype.replace()
String.prototype.trim()
String.prototype.toUpperCase()
Function parameters
Return

Questions

What's the best way to structure a debugging process?

@Eugenie-A Eugenie-A added 🏕 Priority Mandatory This work is expected 🦑 Size Large 4-8 hours 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Submit:PR Module-Structuring-And-Testing-Data The name of the module. labels Feb 4, 2026
function calculateBMI(weight, height) {
// return the BMI of someone based off their weight and height
} No newline at end of file
return (weight / (height * height)).toFixed(1); // toFixed(1) rounds to 1 decimal place.
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.

I expected the function to return a number, not a string.
No, my function didn't return the type of value I was expecting it to, but rather it was returned as a string due to .toFixed(1).
I updated it to return Number( (weight / (height * height)).toFixed(1) ); - This keeps the rounding to 1 decimal place but converts back to a number.

@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 Feb 12, 2026
@cjyuan cjyuan 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 Feb 17, 2026
@cjyuan
Copy link
Contributor

cjyuan commented Feb 17, 2026

What's the best way to structure a debugging process?

I do not understand what you mean. Can you elaborate?

@Eugenie-A
Copy link
Author

What's the best way to structure a debugging process?

I do not understand what you mean. Can you elaborate?

I'm trying to get better at debugging JavaScript code in a consistent, step by step way especially when fixing broken functions or understanding why something fails.

So what I'm asking is what are some reliable structured debugging habits or checklists that experienced developers use?

@cjyuan
Copy link
Contributor

cjyuan commented Feb 17, 2026

The key of debugging is to find out which expression does not evaluate to the expected value or which variable does not hold the expected value.

For small amount of code, we can output the value of suspected expressions or variables.
For larger code base, we can use a debugger. We can use it to set break points, inspect value of variables, and trace the execution of the the code line by line.

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. Module-Structuring-And-Testing-Data The name of the module. 🏕 Priority Mandatory This work is expected 🦑 Size Large 4-8 hours 📅 Sprint 2 Assigned during Sprint 2 of this module Submit:PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants