Repository navigation
London | 26-ITP-May | Abdennour Hachemi| Sprint 1| Refactoring - #1582
AbdennourHachemi wants to merge 11 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| function findMax(elements) { | ||
|
|
||
| let max = -Infinity; | ||
| elements.forEach((element) => { |
There was a problem hiding this comment.
What happens when the documented non-array input "hey" reaches elements.forEach?
To "like" or "dislike" this comment, please follow this link
|
|
||
| if ( | ||
| !Array.isArray(list) || | ||
| list.some((element) => typeof element !== "number") |
There was a problem hiding this comment.
some and reduce both skip missing slots, so calculateMean([1, , 3]) passes validation, sums to 4, and divides by 3. The same validation gap appears in Sprint-1/fix/median.js.
To "like" or "dislike" this comment, please follow this link
| "culateMean requires an array of numbers" | ||
| ); |
There was a problem hiding this comment.
What error message would still satisfy this expectation if the leading cal were missing? The same shortened expected message appears in the other two error tests.
To "like" or "dislike" this comment, please follow this link
|
The CYF AI review has left comments. It will only review a PR one time. When you have addressed these comments, please request review again and a volunteer will take a look. |
iscmiguelsamaniego
left a comment
There was a problem hiding this comment.
Thank you so much for sharing your work across these katas! Your solutions and tests are super clean and aligned with the acceptance criteria.
Just a gentle question: how might edge cases like NaN, sparse slots, empty arrays, or floats (.toBeCloseTo()) behave here? You're doing awesome!
There was a problem hiding this comment.
Thanks so much for sharing! Clean sorting and clear comments—how might Number.isFinite affect tests checking typeof v !== "number", and does the order of the empty-array check matter? Keep going!
There was a problem hiding this comment.
Thanks so much for sharing this! Your dedupe logic works nicely for keeping first occurrences in order.
Just a quick, friendly question to explore: how might array.indexOf(number) === index behave on a very large array, and could === help avoid any surprises with ==? You're doing great—keep it up!
There was a problem hiding this comment.
Thank you so much for sharing the tests again! I really like how clearly you mapped each test to the acceptance criteria.
Just one gentle question to explore: looking at [1, 2,,2, ...], was that extra comma intentional to test a sparse slot, and how might dedupe behave if undefined is explicitly passed instead? You're doing great!
There was a problem hiding this comment.
Thank you so much for sharing this! Using try/catch to translate errors into a readable message is really clean and clear.
Just a gentle question to explore: how might describeMedian behave if an unexpected error without a message is thrown, or if calculateMedian isn't passed as expected in tests? You're doing great!
There was a problem hiding this comment.
Thank you so much for sharing these tests! Replacing that old commented test and covering valid numbers, empty arrays, and non-array inputs really aligns with the acceptance criteria.
Just one gentle question to explore: how might describeMedian behave with an even-length array (like [1, 2, 3, 4]), and could adding a test for that help verify the decimal formatting? You're doing awesome!
There was a problem hiding this comment.
Thank you so much for sharing these tests! Great job covering empty arrays, negatives, decimals, and non-number elements.
Just a gentle question: which acceptance criterion still needs a test at the bottom, and how might NaN behave if passed in an array? You're doing awesome!
There was a problem hiding this comment.
Thank you so much for sharing this! Breaking the validation and calculation into clear numbered steps is super readable.
Just a quick, friendly question: what happens if NaN is in list, and might checking for an empty array before looping save a step? You're doing awesome!
There was a problem hiding this comment.
Thank you so much for sharing these tests! Covering single elements, decimals, negatives, empty arrays, and invalid inputs is super thorough.
Just a quick, friendly question: what happens if a test passes NaN inside an array, and how might .toBeCloseTo() help with floating-point decimals? You're doing great!
There was a problem hiding this comment.
Thank you so much for sharing this! Using .some() and .reduce() makes the intent really clear.
Just a quick, friendly question: how might NaN behave with typeof here, and could intialValue have a quick typo to tidy up? You're doing great!
There was a problem hiding this comment.
Thank you so much for sharing these tests! Great job covering empty arrays, negatives, decimals, and invalid inputs.
Just a quick, friendly question: what happens with 3.1 + 74.6 + 9.87 + 204.33 + 19.5 in floating-point math, and might we also test 42 or no arguments? You're doing awesome!
Task code
CYF-1071