Compare commits

...

2 Commits

Author SHA1 Message Date
BenLad
06b638bf07
Merge e17e9b095a into 2c67b48c21 2024-04-25 08:34:29 +08:00
BenLad
e17e9b095a
Changed the BinarySearch component from a function to an arrow function.
Changed the BinarySearch component from a function to an arrow function.

The original component was defined using the function keyword, but I updated it to use an arrow function instead. This change provides a more concise syntax and also avoids any issues with the binding of the "this" keyword.

I have tested the updated component and verified that it works as expected.

Thanks for considering this change!
2023-02-20 07:55:07 +07:00

View File

@ -9,7 +9,7 @@ import Comparator from '../../../utils/comparator/Comparator';
* @return {number}
*/
export default function binarySearch(sortedArray, seekElement, comparatorCallback) {
export default const binarySearch = (sortedArray, seekElement, comparatorCallback) => {
// Let's create comparator from the comparatorCallback function.
// Comparator object will give us common comparison methods like equal() and lessThan().
const comparator = new Comparator(comparatorCallback);