This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const binarySearch = function (array, target) { | |
// initialise variables to point to bounds of array | |
let bottom = 0; | |
let top = array.length - 1; | |
let middle; | |
while (bottom <= top) { | |
// get index of middle value | |
middle = Math.floor((bottom + top) / 2); | |
const middleValue = array[middle]; |