[Solved] Getting undefined value of objects array


This line is probably not what you intended:

const data = [{}];

That is starting off the array as an array containing one object with no properties. You’re pushing more items in there, but the original empty object is still going to be there. You’re most likely having that come out as your top item after sorting.

Just start off your array as an empty array:

const data = [];

In addition, in your console statement you’re addressing highestMetalValueObj.address, but your objects don’t seem to have that property. You probably meant to use highestMetalValueObj.addressValue instead.

9

solved Getting undefined value of objects array