Here's the implementation of binary search algorithm in javascript:
320 chars19 lines
Here's how to use the binarySearch
function:
139 chars7 lines
The function takes two parameters, an array arr
and a value to be searched target
. It returns the index of the target
in arr
if found, otherwise it returns -1.
gistlibby LogSnag