JavaScript filter() on JSON object?
It seems like you should not be hard-coding concepts such as "kitchen", "garage", etc. into your code at all. You need to design that out.



Also I question the JSON structure.  sensor_* are meaningless property names, giving you an unnecessary level of nesting, so if you have control over JSON generation, you might consider an array of object like:

[
    {
        "location": ...,
        "temp_f": [
            ...
        ]
    },
    {
        ...
    }
]




But let's assume you can't do that, and think of ways we can get you the information make this whole thing more dynamic. I am not sure what params is even used for, so I am discarding this.

api.sensor_data.get(function(data){
    let sensorData = {};
    // loop through each sensoer object, ignore top level key value
    Object.values(data).forEach( (sensor) =&gt; {
        // reduce f_temp array to single entry with highest temp
        // and set to sensorData result object with location as key
        sensorData[sensor.location] = sensor.f_temp.reduce( (acc, metric) =&gt; {
            if(parseFloat(metric.value) &gt; parseFloat(acc.value)) acc = metric;
            return acc;
        }, sensor.f_temp[0]);
    });

    $scope.sensorStats = sensorData;
}




Based on your comment regarding params, you might have something more like this:

    let sensorData = {};

    let sensors = Object.values(data);
    // filter by location
    if (location in params) {
        sensors = sensors.filter( (sensor) =&gt; sensor.location === params.location );
    }
    // loop through each sensor objects        
    sensors.forEach( (sensor) =&gt; {
        let result = null;
        let metrics = sensor.f_temp;
        if(minTimestamp in params) {
            metrics = metrics.filter( metric =&gt; {
                return (Date.parse(metric.timestamp) &gt;= params.minTimeStamp );
            });
        }
        if(maxTimestamp in params) {
            metrics = metrics.filter( metric =&gt; {
                return (Date.parse(metric.timestamp) =&lt; params.maxTimeStamp );
            });
        }
        if(metrics.length &gt; 0) {
        result = metrics.reduce( (acc, metric) =&gt; {
            if(parseFloat(metric.value) &gt; parseFloat(acc.value)) acc = metric;
            return acc;
        }, metrics[0]);
       sensorData[sensor.location] = result;
    });

    $scope.sensorStats = sensorData;
}