I have a long list of number ranges between 0 and 1000000, each correlating to another number.
It's for an HTML form to calculate prices. I thought about using a set of arrays or an if-else chain, but I'm looking for the most efficient way to accomplish the same task.
Here's a sample:
Range | Result |
---|---|
0 - 40000 | 2000 |
40001-50000 | 2500 |
50001-60000 | 3000 |
I'd like to be able to provide the script a number, such as 45000
and have it return 2500 as the result. How can I do this without creating a long if-else chain?