Answers for "find the most expensive or biggest item inside an array"

0

find the most expensive or biggest item inside an array

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
Posted by: Guest on June-10-2021

Code answers related to "find the most expensive or biggest item inside an array"

Browse Popular Code Answers by Language