JSFiddle - React, Tailwind, and code Playground
by aldomatic
JavaScript
var customersArr = [
{
id: 3,
name: 'John Doe'
},
{
id: 4,
name: 'Aldo Doe'
},
{
id: 6,
name: 'Mark Doe'
},
{
id: 2,
name: 'Kelly Doe'
}
];
// find customer by id
var customerPosition = customersArr.map(function(x) {return x.id;}).indexOf(6);
var customer = customersArr[customerPosition];
console.log(customer);