Last active
October 9, 2020 16:34
-
-
Save forrest-akin/dae4a8106b4d410bd2f97dc162723935 to your computer and use it in GitHub Desktop.
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
function search ( nums , target ) { | |
for ( let low = 0 , high = nums.length - 1 , ndx | |
; low <= high | |
; nums[ ndx ] < target ? low = ndx + 1 : high = ndx - 1 | |
) if ( ndx = Math.floor( ( high - low ) / 2 ) + low | |
, nums[ ndx ] === target | |
) return ndx | |
return -1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment