Skip to content

Conversation

@Mahtem
Copy link

@Mahtem Mahtem commented Oct 24, 2025

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

Completed course works of Sprint 2 from module structuring and testing data

Questions

Questions and blockers will be forwarded to slack.

@Mahtem Mahtem added 📅 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. Module-Structuring-And-Testing-Data The name of the module. and removed Module-Structuring-And-Testing-Data The name of the module. labels Oct 24, 2025
Comment on lines +25 to 30
function convertToPercentage() {
const decimalNumber = 0.5;
const percentage = `${decimalNumber * 100}%`;

return percentage;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Without the parameter, the function would always return "50%", which is not very useful.

}

const bmi = weight/(height*height);
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.

Both of these function calls output 123 in the console, but internally in the program,
the number 123 and the string "123" are stored and treated differently.

  console.log(123);
  console.log("123");

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?


// c) What is the return value of pad is called for the first time?
// =============> write your answer here
// =============> 00
Copy link
Contributor

Choose a reason for hiding this comment

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

To more precisely express a value is a string, we can enclsoe the value by a pair of double quotes. For example, "00".


function formatAs12HourClock(time) {
let hours = Number(time.slice(0, 2));
const minutes = time.slice(3);
Copy link
Contributor

Choose a reason for hiding this comment

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

We could also pass a parameter to .slice() to clearly express the intent to extract the last two characters,
without needing to calculate the starting position manually. Can you find out what this parameter is?

suffix = "am";
}

hours = hours % 12 || 12; // convert 0 to 12, 13 to 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain how the expression hours % 12 || 12 convert 0 to 12 and 13 to 1?


// Modified Code:

function formatAs12HourClock(time) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is another function with the same name defined on lines 6-12. Do you still need that function?

@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 Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants