Driver method to test above
let arr = [ " " , " " , " " , " " ] ; let x = " " ; let result = binarySearch ( arr , x ) ; if ( result == - 1 ) document . write ( " " ) ; else document . write ( " " + " " + result + " " ) ;