How can I extract values from a JSON object in JavaScript? Below is the code snippet I've tried:
var obj={"0.5":0.009333, "0.21":0.048667,"0.31":0.070667};
var value =0.21;
var p=0;
for(i=0; i<= obj.length ;i++){
if(value== obj[i]){
p = obj[i]; //I'm expecting p to be 0.048667
console.log("psr is :"+p);
}
}