-
-
Notifications
You must be signed in to change notification settings - Fork 147
London | May-2025 | Ikenna Agulobi | Data Groups | sprint-1 #575
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
…st and to return null if array has no numbers
…is empty should return empty array.
…of original array
…returns first occurence of each element
…rs, return largest number
…turn 0 if array empty
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.
Well done! I've left a few questions
} | ||
//Filtering out numbers from the array without changing the original array. Creates new array filteredNumbersOnly! | ||
const filteredNumbersOnly = list.filter( | ||
(element) => typeof element === "number" && !isNaN(element) |
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.
This is correct! Do you understand why we also need !isNaN
here?
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.
Yes! We need !isNaN in my function so that it filters real usable numbers and ignore anything that is not a real number like 'NaN".
function dedupe(arr) { | ||
const newArray = [... new Set(arr)] | ||
return newArray; | ||
}; |
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.
have you tested this? does it run or is there a syntax error?
Do you understand how the Set works?
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.
I tested my code and it does work.
Set() is a JS object which stores collection of unique values. For instance, in my code "new Set(arr) " filters out any duplicates in the array and creates a set of new values with no duplicates. Then the spread operator converts it back to a new array .
prep-for-data-groups-module/mean.js
Outdated
function calculateMean(list){ | ||
let total = 0; | ||
|
||
for(const item of list){ | ||
total += item/3 | ||
} | ||
return total; | ||
} |
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.
What happens if the array contains more than 3 numbers? does it still correctly calculate the mean?
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.
If the array contains more than 3 numbers, the code will still run but wouldn’t work as we expect because to get the Mean we need to use the length of the array.
So I've updated my code to get the Mean of the array regardless of it's length.
Co-authored-by: Morgan David <32820185+MorganDavid@users.noreply.github.com>
Hi @MorganDavid , Thank you for taking the time to review my PR and for your valuable feedbacks. |
Learners, PR Template
Self checklist
Changelist##
Briefly explain your PR.
This PR includes my completed exercises for Sprint 1 - Data Groups module.
###The exercises included in this PR:###
1- Fix
2- Implement
3- Include
Questions
Ask any questions you have for your reviewer.
Hi!, I don’t have a question at the moment, but I just wanted to let you know that I wasn’t able to complete the stretch project because I’m currently focusing on catching up with the mandatory tasks to stay on track. Thanks!