JSFiddle - React, Tailwind, and code Playground

by baduCleo

JavaScript

var array = [{prodCode: 20, name: "Product 1"}, {prodCode: 21, name: "Product 2"}, {prodCode: 22, name: "Product 3"}]
console.log("Array before removal ", array);
var indexToRemove = array.findIndex(product => product.prodCode == 21)
console.log("about to remove index ", indexToRemove);
array.splice(indexToRemove, 1);
console.log("Array after removal ", array);