I have this range of numbers:
0 -------> 25 -------> 80 ------> 150 small medium large
I want to get a number from 0 to 150 and display whether it is small, medium or large. 30 and 45 are average because they are between 25 and 80 and 5 are small because they are below 25.
I want to create a function that matches this object:
var sizeMap = { small : 25, medium : 80, large : 150 }
(assuming 0 is the smallest number).
The function should look like this:
function returnSize(number) { for (item in sizeMap) ??????? return size }
how to write this function so that it can be flexible for adding new categories (for example: "extra large": 250). Should I present an object as an array?
source share