📜  在数组中找到最昂贵或最大的项目 - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:42.979000             🧑  作者: Mango

代码示例1
let items = [
  {
    itemName: "Effective Programming Habits",
    type: "book",
    price: 13.99
  },
  {
    itemName: "Chromebook 2",
    type: "computer",
    price: 399.99
  },
 {
    itemName: "Programming 101",
    type: "book",
    price: 15.00
  } 
]

let maxItem = items.reduce((max, min) => max.price > min.price ? max : min);

console.log(maxItem.itemName) //Chromebook 2
console.log(maxItem) //Full object