Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUpdate BinarySearch.js #209
Merged
Conversation
The old algorithm didn't work, I believe for two main reasons: 1 - Number.MAX_VALUE is not a valid array index as it is used to represent the highest possible value in javascript (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE); 2 - splice() is not a pure function, every time it is called it has the side effect of modifying the original array (https://www.w3schools.com/jsref/jsref_splice.asp) ; So I rewrote the algorithm, it now returns an index ( -1 if not found ) and it works both on numbers and on strings.
Style change
Style change
Everything else looks fine to me, still I would appriciate if @itsvinayak would review it once |
@Askanders, you can run |
Yes, thank you @ruppysuppy. I have a lot of configuration to do so I haven't installed the package yet, but I'll definitely do it in the future. |
everything seems fine |
sure and thanks for helping @ruppysuppy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Askanders commentedJun 27, 2020
•
edited
The old algorithm didn't work, I believe for two main reasons:
1 - Number.MAX_VALUE is not a valid array index as it is used to represent the highest possible value in javascript (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE);
2 - splice() is not a pure function, every time it is called it has the side effect of modifying the original array (https://www.w3schools.com/jsref/jsref_splice.asp) ;
So I rewrote the algorithm, it now returns an index ( -1 if not found ) and it works both on numbers and on strings.
Welcome to JavaScript community
Describe your change:
Checklist:
Example:
UserProfile.js
is allowed butuserprofile.js
,Userprofile.js
,user-Profile.js
,userProfile.js
are notFixes: #{$ISSUE_NO}
.