Here is the dataset provided
var sampleArray = [
{ "Rating 1": -75 },
{ "Rating 2": -70 },
{ "Rating 3": 98 },
{ "Rating 4": -88 },
{ "Rating 5": 29 },
];
I am looking to organize it in the following manner
- Highest rating
- Lowest rating
- Rating closest to 0 (if there are 2 results, the positive will be chosen example:-1,1 then 1 will be chosen)
My challenge lies in extracting only the second value which represents the rating. I have attempted various codes but so far, I am only able to retrieve the entire value of array 0
function topProduct(productProfitArray) {
return productProfitArray[0];
}