-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
Properly detect min and max element in array #224
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
Conversation
Hello I noticed that the The smallest element in this array is The bug is caused because of the initial value given to the reduced function. I rewrote the 2 declarations using Best of luck! |
Codecov Report
@@ Coverage Diff @@
## master #224 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 143 143
Lines 2554 2554
Branches 422 422
=====================================
Hits 2554 2554 Continue to review full report at Codecov.
|
|
||
// Detect smallest number in array in prior. | ||
const smallestElement = notSortedArr.reduce((accumulator, 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 set smallestElement
to 0
, which is not correct.
The smallest element in this array is 1
.
The correct starting values for the |
@lazarljubenovic not putting |
@yavorski , good catch. Thank you for PR. |
No description provided.