I have a JavaScript object like the following
var items =
{
"k1": "value1",
"k2": "value2",
"k3": "value3"
};
How can I compare key with a fixed number to get key and value of (“k2”, value2) ?
Example: k1 = 9, k2 = 15, k3 = 23; fixed number (fix=12)
I will loop through all items to get only my key and value:
function(fix) {
for(var key in items) {
if (fix > k1 || fix <= k2) {
document.write( key + " : " + items[key] + "<br />");
}
}
}
How can I do that ?
Use this code i hope it will help you.I just edit your code and get value