Skip to content

Conversation

@shreefAhmedM
Copy link

@shreefAhmedM shreefAhmedM commented May 25, 2025

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

Briefly explain your PR.
Her is JavaScript challenges tasks covering exercises, error fixing, code interpretation, and a stretch exploration activity.

Questions

Ask any questions you have for your reviewer.

@shreefAhmedM shreefAhmedM added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label May 25, 2025
@cjyuan
Copy link
Contributor

cjyuan commented May 25, 2025

Please do not request for reviewers. We still have plenty of PRs in Module Onboarding to review. I am afraid the PRs in the second module will have to wait.

Good job in preparing the PR description. You can probably further improve this PR by asking ChatGPT for second opinion or to check for grammar/spelling mistakes.

@alexandru-pocovnicu alexandru-pocovnicu removed their request for review May 25, 2025 21:04
@alexandru-pocovnicu
Copy link

Hi, I think I was tagged by mistake so I'll just go ahead and untag myself, all the best

@cjyuan cjyuan removed their request for review May 25, 2025 21:15
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.

Code is good! I left you some suggestions.

// }

// =============> write your explanation here
// =============> SyntaxError: Identifier 'str' has already been declared
Copy link
Contributor

Choose a reason for hiding this comment

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

The instruction was "write your explanation here".

Can you write your explanation instead of just showing the error message produce by the runtime?

const percentage = `${decimalNumber * 100}%`;
return percentage;
}
console.log(convertToPercentage("0.5")); // ====> 50%
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the parameter be a number (0.5) or a string ("0.5")?

return `The result of multiplying ${a} and ${b} is ${a * b}`
}

console.log(multiply(9, 6)); // ===> The result of multiplying 9 and 6 is 54 No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

A function should only do one specific task.

  • Calculate the product of two numbers (Yes)
  • Return the result in a specially formatted string (Well, what if I want to format the result in different ways?)

Can you reimplement the function to improve its reusability?

// return the BMI of someone based off their weight and height
} No newline at end of file
let 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.

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?

// Use the MDN string documentation to help you find a solution
// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
function toUpperSnakeCase(str){
let SnakeCaseStr = str.replace(/ /g, "_")
Copy link
Contributor

Choose a reason for hiding this comment

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

It is more common practice to begin variable names with a lowercase letter. Names that start with an uppercase letter are typically reserved for user-defined data types or class names.

Comment on lines +11 to +12
const pounds = paddedPenceNumberString.substring(0,paddedPenceNumberString.length - 2);
const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0");
Copy link
Contributor

Choose a reason for hiding this comment

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

You should take a look at .slice(). With this function, lines 11-12 can be rewritten as

    const pounds = paddedPenceNumberString.slice(0, -2);
    const pence = paddedPenceNumberString.slice(-2);   // .padEnd() is redundant regardless of which function we use

return `${hours - 12}:00 pm`;
const minutes = time.slice(3);
let currTime = "am";
let HoursModefied = hours;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should begin variable name with a lowercase letter.

GitHub even assign a different color to identifiers that begin with an uppercase letter:
image

}
return `${time} am`;

const formattedHour = HoursModefied < 10 ? "0" + HoursModefied : HoursModefied.toString();
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 a String function you can use to make this statement shorter (and clearer).

Comment on lines +39 to +44
const currentOutput3 = formatAs12HourClock("01:00");
const targetOutput3 = "01:00 am";
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.

"12:00" would make a good edge case to test.

Also, we should also test cases where minute part is not equal to "00".

@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 Jun 5, 2025
@shreefAhmedM shreefAhmedM deleted the acoursework/sprint-2 branch September 14, 2025 10:30
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants