Develop a function named "json_filter" that accepts a JSON-formatted string as input. The accepted format is an array of objects, where each object contains keys for "mass," "density," "temperature," and "velocity," each mapped to a floating-point number. This function should output the input as a JSON string in the same format but only include objects with a temperature greater than 31.92.
function json_filter(format){
var array = JSON.stringify(format);
var filteredArray = [];
for (var i = 0; i < array.length; i++){
if (array[i].temperature > 31.92){
filteredArray.push(array[i]);
}
}
return JSON.parse(filteredArray);
}
Upon running this code, an error message might appear like the one below:
Error while processing 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...]: TypeError: Cannot read property 'temperature' of undefined
If you encounter this issue or need help correcting it, feel free to ask for assistance.