I have a state in React that contains this values :
{
income 1 : 500,
income 2 : 300,
income 3 : 1000
}
This state extend, the customer can add or delete rows in the state, so I need to find in a dynamic way the key/value where the value is the higher in the Object.
I tried this, but it retrieve only the first key/value :
export const maxIncome = (userWalletIncomes) => {
for (const [key, value] of Object.entries(userWalletIncomes)) {
return `${key} : ${Math.max(value)}`
}
}
Any idea ?