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