Skip to content

London | 26-ITP-Jan | Oussama Mouggal | Sprint 1| Data-Groups#975

Open
Oussama-Mouggal wants to merge 7 commits intoCodeYourFuture:mainfrom
Oussama-Mouggal:sprint1/data-groups
Open

London | 26-ITP-Jan | Oussama Mouggal | Sprint 1| Data-Groups#975
Oussama-Mouggal wants to merge 7 commits intoCodeYourFuture:mainfrom
Oussama-Mouggal:sprint1/data-groups

Conversation

@Oussama-Mouggal
Copy link

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

I added tests and implemented code and checked code failure in order to pass the npm tests.

@github-actions

This comment has been minimized.

@Oussama-Mouggal Oussama-Mouggal added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 3, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 3, 2026
@Oussama-Mouggal Oussama-Mouggal changed the title London | 26-ITP-Jan | Oussama Mouggal | Sprint-1| Data-Groups London | 26-ITP-Jan | Oussama Mouggal | Sprint 1| Data-Groups Mar 3, 2026
@Oussama-Mouggal Oussama-Mouggal added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 3, 2026
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 correct and tests are well prepared.

I just have some suggestions.

Comment on lines +11 to +18
}
const numbers = list.filter(val => typeof val === 'number' && !isNaN(val));
if (numbers.length === 0) {
return null;
}
numbers.sort((a, b) => a - b);

const length = numbers.length;
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation is off.

Have you installed the prettier VSCode extension and enabled "Format on save/paste" on VSCode,
as recommended in
https://github.com/CodeYourFuture/Module-Structuring-and-Testing-Data/blob/main/readme.md
?


If you have enabled "Format on save" but it is not working, it is likely that you haven't assign a formatter for JS file. This could happen if you have zero or multiple extensions that can format .js file.

If you have installed "Prettier" extension. To assign it as the formatter of JS code, you can try:

  1. Use "Format document" to format the JS file. Sometimes, VSCode will ask you to choose a formatter, and you can manually select "Prettier".
  2. Edit settings.json and set Prettier as the default formatter for JS.
    See: https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for your valuable feedback.I fixed it and corrected the indentation in median.js and configured workspace VS Code settings to use Prettier as the default formatter for JavaScript with format-on-save/paste enabled.

Comment on lines +37 to +39
test("given decimal numbers, returns correct total", () => {
expect(sum([1.5, 2.5, 3.25])).toBe(7.25);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Decimal numbers in most programming languages (including JS) are internally represented in "floating point number" format. Floating point arithmetic is not exact. For example, the result of 46.5678 - 46 === 0.5678 is false because 46.5678 - 46 only yield a value that is very close to 0.5678. Even changing the order in which the program add/subtract numbers can yield different values.

So the following could happen

  expect( 1.2 + 0.6 + 0.005 ).toEqual( 1.805 );                // This fail
  expect( 1.2 + 0.6 + 0.005 ).toEqual( 1.8049999999999997 );   // This pass
  expect( 0.005 + 0.6 + 1.2 ).toEqual( 1.8049999999999997 );   // This fail

  console.log(1.2 + 0.6 + 0.005 == 1.805);  // false
  console.log(1.2 + 0.6 + 0.005 == 0.005 + 0.6 + 1.2); // false

Can you find a more appropriate way to test a value (that involves decimal number calculations) for equality?

Suggestion: Look up

  • Checking equality in floating point arithmetic in JavaScript
  • Checking equality in floating point arithmetic with Jest

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 the feedback.I updated the decimal test in Sprint-1 to use Jest’s floating-point matcher instead of exact equality.

@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 Mar 17, 2026
@Oussama-Mouggal Oussama-Mouggal added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 21, 2026
@cjyuan
Copy link
Contributor

cjyuan commented Mar 21, 2026

Changes look good. Well done.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 21, 2026
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants