I have an object like this:
var rock = {
5: 0.5,
0: 0.8,
10: 0.3,
2: 1.0,
}
I have a number like 4.3
and I need the index and value of the prior and following numer. In this example I would get
var timeA = 2;
var valueA = 1.0
var timeB = 5;
var valueB = 0.5;
My first idea was something like a for-loop, but I don't know how to make sure that it's in the right order.