Basically what I'm trying to achieve, is the lowest integer from an object thats in an array with other objects.
r.Collection
is an array that holds 3 objects, so it looks something like this:
[{foo:"bar",abc:"xyz",number:1},{foo:"car",abc:"hcu",number:2},{foo:"tar",abc:"uif",number:3}]
Now the goal, is to sort through this array. and look at each of the number values, once it finds the lowest value. I need it to pull that entire object out of the array to use later.
Currently what i'm trying to do isn't working and i'm not sure. I could be doing this totally wrong
for (o in r.Collection) {
var data = r.Collection[o]
console.log(Math.min(data.number))
}
I know to use Math.min to find the smallest number in an array, but when I run this code, every object gets printed.
How do I sort through this array, to pull our the object with the lowest number value?