diff --git a/snippets/binarySearch.md b/snippets/binarySearch.md index 55541ebe8..deef65478 100644 --- a/snippets/binarySearch.md +++ b/snippets/binarySearch.md @@ -14,16 +14,13 @@ Finds the index of a given element in a sorted array using the binary search alg const binarySearch = (arr, item) => { let l = 0, r = arr.length - 1; - while (l <= r) { const mid = Math.floor((l + r) / 2); const guess = arr[mid]; if (guess === item) return mid; - if (guess > item) r = mid - 1; else l = mid + 1; } - return -1; }; ```