js: basic binary search