Driver code
let arr = [ 2 , 3 , 4 , 10 , 40 ] ; let n = arr . length ; let x = 10 ; let result = randomizedBinarySearch ( arr , 0 , n - 1 , x ) ; if ( result == - 1 ) document . write ( " " ) ; else document . write ( " " , result ) ;