Skip to content

Glasgow | May-2025 | Adiyah Farhan | Sprint-2 #515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

AdiyahFarhan
Copy link

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Files in the folder 1-key-errors have been updated with explanation and all errors have been resolved.
Files in the folder 2-mandatory-debug have been updated with corrected code.
Files in the folder 3-mandatory-implement have been updated with the required codes as per given task
The file in the folder 4-mandatory-interpret has been updated with all questions answered
The file in the 5-stretch-extend folder has been updated to include a new test using a different number of minutes as input.

Questions

Not yet.

@AdiyahFarhan AdiyahFarhan added Needs Review Participant to add when requesting review 📅 Sprint 2 Assigned during Sprint 2 of this module labels Jun 11, 2025
@cjyuan cjyuan added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Participant to add when requesting review labels Jun 21, 2025
Comment on lines 31 to 41

const decimalNumber = 0.5;

function convertToPercentage() {
const percentage = `${decimalNumber * 100}%`;

return percentage;
}

result = convertToPercentage();
console.log(result);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you introduce a parameter to the function so that we can reuse the function's code with different numbers.

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 modified the file by adding a parameter to the function to enhance its reusability.

Comment on lines 18 to 23
const heightSquare = height * height;
const BMI = weight / heightSquare;
const scaledBMI = BMI.toFixed(1);
return scaledBMI;
}
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 the function to return? A number or a string?
Does your function return the type of value you expect it to return?

Copy link
Author

Choose a reason for hiding this comment

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

The function returns the String value while we expect it to return a Number. I have updated my function by explicitly converting the type of return value of the function to Number.

Comment on lines 8 to 29
function convertToPounds(penceString) {
const penceStringWithoutTrailingP = penceString.substring(
0,
penceString.length - 1
);

const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
const pounds = paddedPenceNumberString.substring(
0,
paddedPenceNumberString.length - 2
);

const pence = paddedPenceNumberString
.substring(paddedPenceNumberString.length - 2)
.padEnd(2, "0");

const convertAmount = "£" + pounds + "." + pence;
console.log(convertAmount);
}

convertToPounds("399p");
convertToPounds("450p");
Copy link
Contributor

Choose a reason for hiding this comment

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

When we designed a function to print the result instead of returning it, we limit how the result can be used.

For example, we cannot show the result in a dialog box via alert( convertToPounds("1234p")) or save the result to a file.

Copy link
Author

Choose a reason for hiding this comment

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

Acknowledged.
I have updated the function so that it returns the convertAmount instead of printing it.


// 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.

We can enclose a value in double quotes to indicate that it is a string, e.g., "00".

Copy link
Author

Choose a reason for hiding this comment

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

Acknowledged. I have updated the file by enclosing a value in the double quotes.

Comment on lines +27 to +33

const currentOutput3 = formatAs12HourClock("23:45");
const targetOutput3 = "11:45 pm";
console.assert(
currentOutput3 === targetOutput3,
`current output: ${currentOutput3}, target output: ${targetOutput3}`
);
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 add a few more test cases to test your function? In particulars, "00:59", and "12:34".

Copy link
Author

Choose a reason for hiding this comment

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

Two more test cases ("00:59" and "12:34") added to test the function. The function has been updated in order to pass all tests.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jun 21, 2025
@AdiyahFarhan
Copy link
Author

Thank you for taking the time to review this @cjyuan . I have updated the files and incorporated the suggested changes in it. Please have a look.

@AdiyahFarhan AdiyahFarhan added Needs Review Participant to add when requesting review and removed Reviewed Volunteer to add when completing a review labels Jun 21, 2025
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

Changes look good. Well done.

const decimalNumber = 0.5;

function convertToPercentage() {
function convertToPercentage(decimalNumber) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: You could also keep the original global variable decimalNumber should you need to, even if it has the same name as the parameter. If you are interested in know why, you can look up "How JS resolve conflicting name".

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 this valuable information.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and review comments have been addressed and removed Needs Review Participant to add when requesting review labels Jun 21, 2025
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 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