Suppose we have an array
car = [
{
id:355,
wheels:3,
},
{
id:3624,
wheels:2,
},
{
id:325,
wheels:4,
},
{
id:744,
wheels:3,
},
How would I go about finding the minimum and maximum of the wheels
property?
How I thought it should be done
My thoughts are we could extract the value of wheels from every object and store it in a new array then use the sort function to first sort the quantities in the (default) lexicographical order then just use array.sort((a,b) => a-b)
to sort them in the ascending order after that I can use
const min = array[0]
const max = array[array.length-1]
at index 0 would be the min and length-1
would be the max. I am unable to get the value from the original array and store it in a new array also I would appreciate some different and/or easier methods.