Write a function named "json_filter" that takes a JSON formatted string as a parameter in the format of an array of objects where each object has keys "mass", "density", "temperature", and "velocity" and each key maps to a floating point number. This function should return the input as a JSON string in the same format but with only the objects with temperature greater than 31.92
function json_filter(format){
var array=JSON.stringify(format);
var array2 = [];
for (var i = 0; i<array.length;i++){
if (array.i.temperature>31.92){
array2.push(array[i]);
return JSON.parse(array2);
}
}
}
When I run this, this is what it says:
error on input ['[{"velocity": 11.33, "mass": 14.56, "density": 165.09, "temperature": 29.92}, {"velocity": 57.86, "mass": 52.23, "density": 770.6, "temperature": 35.61}, {"velocity": 62.23, "mass": 84.85, "density": 85.22, "temperature": 51.66}, {"velocity": 16.63, "mass": 51.23, "density": 995.61, "temperature": 10.27}, {"velocity": 31.16, "mass": 71.76, "density": 967.53, "temperature": 50.43}, {"velocity": 14.35, "mass": 0.92, "density": 808.42, "temperature": 69.32}, {"velocity": 85.43, "mass": 41.07, "density": 899.84, "temperature": 51.05}]']: TypeError: Cannot read property 'temperature' of undefined
I'm not sure how to fix this, if anyone could help I'd greatly appreciate it.