-
-
Notifications
You must be signed in to change notification settings - Fork 153
LONDON | MAY2025 | EMILIANO URUENA | DATA_GROUPS | Sprint-1 #546
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
base: main
Are you sure you want to change the base?
Conversation
return null | ||
} | ||
// the next code from 13 to 16create a new Array called listFiltered checking if the elements are numbers and no NaN> | ||
const listFiltered = list.filter(checkElement); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using an anonymous function here will make this method more concise (instead of checkElement).
return median | ||
} else { | ||
const median = listFiltered.splice(middleIndex, 1)[0]; | ||
return median |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using an Inline return statement on this line and line 28 is best practice
} | ||
if (elements.length === 0) return '-Infinity'; | ||
if (elements.length === 1) return elements; | ||
let maxNum = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is maxNum an array? A number type as the return value is most appropriate for this function.
|
||
); | ||
[ | ||
{ input: ['e','r','n','a','l','g','l'], expected: 'Family'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 'Family' the best value to return in this case? Why not return something like null.
noNum.push(elements[i]) | ||
} | ||
} | ||
if (elements.length === noNum.length) return 'Family' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, is returning 'Family' the most appropriate here? Why not either 0 or null?
if (typeof elements[i] === 'number'){ | ||
sum += elements[i]; | ||
} else { | ||
noNum.push(elements[i]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to check if the array contains no numbers, instead of making a new array and adding all the elements to it? Every array in your code will use more memory, and for very large inputs this will be inefficient.
A good start - but there is still some work to do. Please address the comments and I will review it again. |
Self checklist
Changelist
Sprint 1 - Module DATA GROUPS
COMMITS: