const arr = [{a:5},{d:6},{g:0},{b:3},{c:1}];
let max = null;
let result;
for (const currentObj of arr) {
const currentValue = currentObj[Object.keys(currentObj)[0]];
const currentKey = Object.keys(currentObj)[0];
if (max < currentObj[currentKey] || max === null) {
max = currentValue;
result = currentKey;
}
}
console.log(result);
const maxKey = arr.reduce((a,c,v)=>(v=Object.values(c)[0],v<a.v?a:{k:Object.keys(c)[0],v:v}),{k:0,v:-Infinity}).k;
const maxElem = arr.reduce((a,c,v)=>(v=Object.values(c),v<a.v?a:{k:c,v:v}),{k:0,v:0}).k;
let max = arr[0]
arr.slice(1).forEach(function(elem) {if(Object.values(max)[0]<Object.values(elem)[0]) {max = elem}});
const arr = [{a:5},{b:3},{c:1},{d:6}];
let vals = arr.map(v=>Object.values(v)[0]);
let key = Object.keys(arr[vals.indexOf(Math.max(...vals))])[0];
console.log(key)