I have an array in my Vue.js code with values 25, 100, 250, and 500. I am looking to find the key value that matches a specific range. For example, if the input is 5, then the output should be 25. However, the code I tried returns all values within the range.
let input = 5
let myarray = [25, 100, 250 ,500]
this.myarray.forEach((val, q) => {
if(val >= input) {
//console.log('Do something here')
}
});
Edit:
For instance, if the input is 5
which falls between 0-25
, the desired output should be 25
. Similarly, if the input is 30
falling between 25-100
, the expected output would be 100
from the array.