I was able to figure out how to return the highest number from a associative array with multiple objects. But I need the whole object.
I prepared this example:
var data = [
{ nr: 235, text: "foo" }
,{ nr: 351, text: "bar" }
];
var highestNr = Math.max.apply(null, Object.keys(data).map(function(e) {
return data[e]['nr'];
}));
var index = "???";
console.log("Highest 'nr': " + highestNr);
console.log("Index at nr "+ highestNr + ": " + index);
//console.log(data[index]);
I need the index or the whole object. I need to show the text from the object with the highest number.