var obj={'one':1,'two':50,'three':75,'four':12}
This is object from which i want the output as 'three':75, this is key value pair for maximum value in object. My constraint is not to use for loop and any library. Is it possible??
By the way I found another solution but it also uses loop.
var obj = {'one': 1, 'two': 50, 'three': 75, 'four': 12};
var maxKey = Object.keys(obj).sort(function (a, b) {
return obj[a] < obj[b];
})[0];
var result = {};
result[maxKey] = obj[maxKey];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With