Skip to content

London | May-2025 | Reza Jahanimir | sprint1 #531

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 9 commits into
base: main
Choose a base branch
from

Conversation

Reza-Jahanimir
Copy link

@Reza-Jahanimir Reza-Jahanimir commented Jun 27, 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

I have tried my best to complete the tasks and write logical testing for them

Questions

Ask any questions you have for your reviewer.

@Reza-Jahanimir Reza-Jahanimir added 📅 Sprint 1 Assigned during Sprint 1 of this module Needs Review Participant to add when requesting review labels Jun 27, 2025

// If the length of the sorted list is even, add 0.5 to the middle number
if (sortedList.length % 2 === 0) {
return (sortedList[middleIndex - 1] + 0.5);
Copy link

Choose a reason for hiding this comment

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

Can you think of a test case where this logic will fail? May be add it to median.test.js as well :)

Copy link
Author

Choose a reason for hiding this comment

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

Rather than thinking through the math, I took the lazy route.

Copy link

Choose a reason for hiding this comment

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

amazing! now just uncomment the correct implementation so that all tests are green again

Copy link
Author

Choose a reason for hiding this comment

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

done

Copy link

Choose a reason for hiding this comment

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

thanks

// Iterate through the array
// If the item is not in the set, add it to both the set and the result array
for (const item of array) {
if (!seen.has(item)) {
Copy link

Choose a reason for hiding this comment

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

Good work! Can you explain why the if condition is necessary here?

Copy link
Author

Choose a reason for hiding this comment

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

// if will compare the item with the item inside seen and as seen is a set it will not allow duplicate values
// when we loop through the array it will check if the item is already in the set or not
// if it is the if condition will be false and it will not add the item to the result array
// if it is not in the set it will add the item to the set and also to the result array
// so at the end we will have a result array with unique values only

if (numericValues.length === 0) return -Infinity;

// Return the largest number in the sorted list
return Math.max(...numericValues);
Copy link

Choose a reason for hiding this comment

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

good code, but the comment has an inaccuracy. Please review the comment above this line

Copy link
Author

Choose a reason for hiding this comment

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

your are right I am not working with a sorted array, i am simply filtering numeric values and getting the max

// If the sorted list is empty, return null
if (numericValues.length === 0) return 0;

// Return the largest number inMath.sum(...numericValues); the sorted list
Copy link

Choose a reason for hiding this comment

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

the comment is not related to the code below?

@@ -1,951 +1,1029 @@
-10
Copy link

Choose a reason for hiding this comment

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

Great job solving the stretch. But any reason to push the input changes as part of the MR?

Copy link
Author

Choose a reason for hiding this comment

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

I thought it is mandatory. Sorry my mistake

@mhmdk mhmdk added Reviewed Volunteer to add when completing a review and removed Needs Review Participant to add when requesting review labels Jul 9, 2025
@Reza-Jahanimir Reza-Jahanimir added Needs Review Participant to add when requesting review and removed Reviewed Volunteer to add when completing a review labels Jul 9, 2025
@mhmdk mhmdk 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 Jul 9, 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 1 Assigned during Sprint 1 of this module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants