Binary Search Take One: function binarySearch(items, value) { let first = 0, last = items.length - 1, middle = Math.floor((last + first)/2); while(items[middle] != value && first < last) { if (value < items[middle]) { last = middle - 1; } else if (value > items[middle]) { first = middle + 1; } middle = Math.floor((last + first)/2); } return (items[middle] != value) ? -1 : middle; }
@rabbigreenberg
reactiverabbi.io