score:0

Accepted answer
const products=[{type:"mb",name:"Asus Motherboard",price:"320",link:"products/asusmb.html",image:"/Eshop_project/img/asusmb.jfif"},{type:"cpu",name:"Intel Core i3",price:"150",image:"../img/corei3.jfif"},{type:"cpu",name:"Intel Core i5",price:"300",image:"../img/corei5.jfif"},{type:"cpu",name:"Intel Core i7",price:"450",image:"../img/corei7.jfif"},{type:"cpu",name:"Intel Core i9",price:"600",image:"../img/corei9.jfif"},{type:"ram",name:"Corsair 16gb",price:"80",image:"../img/corsair16gb.jfif"},{type:"psu",name:"Corsair PSU",price:"100",image:"../img/corsairpsu.jfif"},{type:"ram",name:"Crucial 32gb",price:"160",image:"../img/crucial32gb.jfif"},{type:"gpu",name:"Nvidia Geforce RTX3070",price:"750",image:"../img/gforce 3070.jfif"},{type:"gpu",name:"Nvidia Geforce RTX 3080",price:"950",image:"../img/gforce_3080.jfif"},{type:"gpu",name:"Nvidia Geforce RTX 3090",price:"1200",image:"../img/gforce_3090.jfif"},{type:"mb",name:"Gigabyte Motherboard",price:"400",image:"../img/gigabytemb.jfif"},{type:"psu",name:"Gigabyte PSU",price:"80",image:"../img/gigabytepsu.jfif"},{type:"ram",name:"Kingston 16gb",price:"90",image:"../img/kingston16gb.jfif"},{type:"mb",name:"MSI Motherboard",price:"300",image:"../img/msimb.jfif"},{type:"case",name:"Phanteks Case",price:"70",image:"../img/Phaktekscase.jfif"},{type:"gpu",name:"AMD Radeon 6500",price:"500",image:"../img/radeon_6500.jfif"},{type:"gpu",name:"AMD Radeon 6800",price:"650",image:"../img/radeon_6800.jfif"},{type:"gpu",name:"AMD Radeon 6900",price:"800",image:"../img/radeon_6900.jfif"},{type:"cpu",name:"AMD Ryzen 3790",price:"400",image:"../img/ryzen3790.jfif"},{type:"cpu",name:"AMD Ryzen 5600",price:"550",image:"../img/ryzen5600.jfif"},{type:"cpu",name:"AMD Ryzen 5800",price:"700",image:"../img/ryzen5800.jfif"},{type:"psu",name:"Seasonic PSU",price:"95",image:"../img/seasonicpsu.jfif"},{type:"case",name:"Zalmancase",price:"90",image:"../img/zalmancase.jfif"},{type:"psu",name:"Evga PSU",price:"80",image:"../img/evgapsu.jfif"}];

const search = 'Corsair 16gb';

// Find the product
const product = products.find(product => product.name === search);

// Increase the price
++product.price;

// Filter out the object from the array
const filtered = products.filter(product => product.name !== search);

// Create a new array from the filtered array,
// and the updated object.
const newProducts = [...filtered, product ];

console.log(newProducts);

score:0

const changeInArr = (name, newValue, key) => {
const newArr = yourArray.map(elem => {
if (name === item.name) {
item[key] = newValue
}
return item
}
return newer
}

score:0

const products = [
  {
    type: 'cpu',
    name: 'AMD Ryzen 5800',
    price: '700',
    image: 'img/ryzen5800.jfif'
  },
  {
    type: 'cpu',
    name: 'AMD Ryzen 6000',
    price: '800',
    image: 'img/ryzen6000.jfif'
  }
]

const productObj = products.reduce((obj, product) => {
  return {
    ...obj,
    [product.name]: product
  }
}, {})

console.log(productObj)
console.log(productObj['AMD Ryzen 6000'])

Related Query

More Query from same tag