Jquery : Set Value for a Range in a Dictionary -
i want set values range in jquery dictionary object somthing this
var temp_dict = {'1-10': 'woolen', '11-25':'light woolen', '26-36':'light cotton'} here keys 1-10, 11-25, 26-36 different ranges of temprature. want store in dictionary , call them :
alert(temp_dict[15]); so checks in range , returns appropriate result.
is there way achieve this??
function gettemp(t) { (var key in temp_dict) { var range = key.split("-"); if (t >= range[0] && t <= range[1]) return temp_dict[key]; } } var temp = gettemp(15);
Comments
Post a Comment