diff --git a/algorithms/searching/binary-search/binary-search.js b/algorithms/searching/binary-search/binary-search.js index b40ceb9..837d2fe 100644 --- a/algorithms/searching/binary-search/binary-search.js +++ b/algorithms/searching/binary-search/binary-search.js @@ -44,7 +44,7 @@ function binarySearch(items, value){ } //recalculate middle - middle = Math.floor((stopIndex + startIndex)/2); + middle = startIndex + Math.floor((stopIndex - startIndex)/2); } //make sure it's the right value