I'm looking to compare objects in an array based on a specific property. Here's the array I have:
var myArray = [
{"ID": 1, "Cost": 200},
{"ID": 2, "Cost": 1000},
{"ID": 3, "Cost": 50},
{"ID": 4, "Cost": 500}
]
My goal is to focus on the "cost" property and find both the minimum and maximum values. One approach could be extracting the cost values into a separate javascript array and then using the Fast JavaScript Max/Min.
But, I'm curious if there's a more direct way to achieve this without having to create an additional array, utilizing the object properties (in this case "Cost") directly. Is there a simpler solution available?