Commit 67c67958 authored by yann300's avatar yann300

fix findClosestIndex

parent 842cc983
......@@ -99,9 +99,9 @@ module.exports = {
}
var index = this.findLowerBound(target, array)
if (index < 0) {
return array[0]
return 0
} else if (index >= array.length - 1) {
return array[array.length - 1]
return array.length - 1
} else {
var middle = (array[index] + array[index + 1]) / 2
return target <= middle ? index : index + 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment