Lookup closest matching value of array and return array index number

Sounds like a google JavaScript problem.