update javascript array element

1. without map: //create a copy of summer fruits. const summerFruitsCopy = […summerFruits]; //find index of item to be replaced const targetIndex = summerFruits.findIndex(f=>f.id===3); //replace the object with a new one. summerFruitsCopy[targetIndex] = fruit;