Skip to content
Advertisement

Get match range value from the array in vuejs

I have below types of array in my vue js. Now I want to find the value key value of match the range. So it’s fall in 25 range so my output should be 25. I tried below code but it always return all the range.

JavaScript

Edit:

My input is 5 and it’s fall between 0-25 so I want to get 25 value from my array. Same if my input is 30 it’s fall between 25-100, in this case I want 100 as value from the array

Advertisement

Answer

You can find the index of the first value that is greater then input. I am assuming the array is sorted,

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement