I need to find extreme values in an object with given average number but honestly I have no idea how to approach to this problem. so I have an object and average with values like that:
const avg = 0.5;
const myjson = {
'key1': 0.5,
'key2': 0.8,
'key3': 0.3,
'key4': 0.2,
'key5': 0.5,
};
So basically average is 0.5, and I wish to get biggest extremes, in above example it would be 'key2' and 'key4'.
so the output should look like this:
const reducedJson = {
'key2': 0.8,
'key4': 0.2,
}
Also in case if there is 3 exteme values, for example there would be 'key6': 0.2, I should return three extremes because two are same.
Sorry that no my code attempts but as I said, I need some help or tip at least because I don't know how to start...