I have an object in JavaScript and I would like to find the one value that is an odd number, then return that value's corresponding key. For example:
const myObject = {
'a': 4,
'b': 6,
'c': 7,
'd': 8
}
From this, I would like to return 'c'. The following is what I have attempted, but I get an error.
const myObject = {
'a': 4,
'b': 6,
'c': 7,
'd': 8
}
myObject.forEach((i) => {
if (counts.value[i] % 2 === 0)
return counts.key[i];
});