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
function that's looking for item with the specific property'x maximum:
function getMax(array, propName) {
var max = 0;
var maxItem = null;
for(var i=0; i max) {
max = item[propName];
maxItem = item;
}
}
return maxItem;
}
usage:
$(document).ready(function() {
$('#getMaxBtn').click(function() {
var max = getMax(jsonArray, 'ppg');
alert(max.player);
});
});