Getting max value(s) in JSON array

前端 未结 11 1688
醉梦人生
醉梦人生 2020-12-06 05:56

I\'m trying to create a JavaScript function which takes information from an array in an external JSON and then takes the max value (or the top 5 values) for one of the JSON

11条回答
  •  北海茫月
    2020-12-06 06:33

    function getMaxOfJson(jsonalreadyparsed, property) {
        var max = null;
        for (var i=0 ; i max){
    
                    max = jsonalreadyparsed[i][property];
    
                }
    
            }
    
        }
        return max;
    }
    

    This works for me.

提交回复
热议问题