Skip to content

West-Midlands | 26-ITP-May | Maryam Janjua | Sprint 2 | Sprint 2 Coursework#1523

Open
maryam-devio wants to merge 14 commits into
CodeYourFuture:mainfrom
maryam-devio:acoursework/sprint-2
Open

West-Midlands | 26-ITP-May | Maryam Janjua | Sprint 2 | Sprint 2 Coursework#1523
maryam-devio wants to merge 14 commits into
CodeYourFuture:mainfrom
maryam-devio:acoursework/sprint-2

Conversation

@maryam-devio

Copy link
Copy Markdown

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

In this coursework, I completed the JavaScript exercises for Sprint 2. I practiced writing reusable functions, testing different inputs and edge cases, debugging code, and using built-in string methods. These exercises helped me improve my understanding of functions, loops, conditionals, and problem-solving in JavaScript.

@maryam-devio maryam-devio 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. labels Jul 17, 2026
@hey-hammad hey-hammad added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 20, 2026
console.log(decimalNumber);
console.log(decimalNumber);*/

function convertToPercentage(decimalNumber) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good catch. However, please review the function's output, it seems to be returning the same result for every input.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I have corrected the issue by removing the reassignment of the function parameter. The function now uses the argument passed to it, so it returns the correct percentage for different input values.

// return the BMI of someone based off their weight and height
} No newline at end of file
const squareHeight = height * height;
const div = weight / height;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please review the BMI calculation formula in the instructions above again.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for pointing that out! Oops, my bad—I mistakenly divided by the height instead of the squared height. I've corrected the BMI calculation to use the proper formula. Thanks for catching that!

// 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 SnakeUpperCase(str){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The logic looks good, but the function name could be more descriptive. Also, you don't need to loop over every character in the string before calling replaceAll(), since it already replaces all occurrences.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll

Copy link
Copy Markdown
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 that out! I understand that the loop was unnecessary since replaceAll() already replaces all occurrences in a single call. I've removed the loop and updated the function name to be more descriptive. Thanks for the helpful feedback!

// You will need to declare a function called toPounds with an appropriately named parameter.

// You should call this function a number of times to check it works for different inputs
function ConversionPenceToPounds(penceString){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good job turning the code into a reusable function. A few things to improve:

  • The function name could be more concise and descriptive, please review the instruction.
  • paddedPenceNumberString and pounds should be declared with const or let to avoid creating global variables.
  • There is duplicated code where paddedPenceNumberString and pounds are assigned twice.
  • Consider testing a few more edge cases, such as "1p" or "100p".

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I've updated the function name to toPounds, declared paddedPenceNumberString and pounds with const, removed the duplicated assignments, and added tests for the suggested edge cases, including 1p and 100p (as well as a few others). Thanks for the helpful suggestions!

`current output: ${currentOutput5}, target output: ${targetOutput}`
);

const currentOutput5 = formatAs12HourClock(":00");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

there is a duplicate variable declaration that will cause the tests to fail before running.

@hey-hammad hey-hammad added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jul 20, 2026
@hey-hammad

Copy link
Copy Markdown

@maryam-devio have you pushed your changes? I don't see the updated code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Structuring-And-Testing-Data The name of the module. 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