I have task where customer pick time range but for different time there is different price, i have created 2 select fields with options of the time:

```
From time
<select>
  <option value="1">22:00</option>
  <option value="2">23:00</option>
  <option value="3">00:00</option>
  <option value="4">01:00</option>
</select>
etc...

```

```
to time
<select>
  <option value="5">04:00</option>
  <option value="6">05:00</option>
  <option value="7">06:00</option>
  <option value="8">07:00</option>
</select>
etc...

```

Then i created array where i set key to match option value.

```
var prices = {1: 100, 2: 125, 3: 125, 4: 150, 5: 150, };

```

Now the problem is how i can return range of selected dates.

Lets say i pick from 22:00h to 04:00h on select picker now how to filer array to get all keys from 1 - 5 and then get all values add to final price.

```
  for (var cost in prices) {
      sum += prices[cost];
  }
  console.log(sum); 

```