比如有以下对象
const obj = {
num1: 1000,
num2: 800,
num3: 900,
}
期望得到 num1: 1000这一项。
js实现代码:
export const maxIncome = (userWalletIncomes) => {
let maxValue = 0;
let maxKey = '';
for (const [key, value] of Object.entries(userWalletIncomes)) {
if(value > maxValue) {
maxValue = value;
maxKey = key
}
}
return `${maxKey} : ${maxValue}`
}
标签:找出,const,num1,maxValue,value,js,maxKey,一项
From: https://www.cnblogs.com/ZerlinM/p/17383819.html