JSFiddle - React, Tailwind, and code Playground
HTML
<div id="content"></div>
JavaScript
const customers = [
{
id: 1,
name: "Joe",
selected: false
},
{
id: 2,
name: "Hank",
selected: false
},
{
id: 3,
name: "Wanda",
selected: false
}
];
const index = customers.findIndex(function(customer) {
return customer.id == 2;
});
const html = "Index of found item is " + index;
document.getElementById('content').innerHTML = html;