JSFiddle - React, Tailwind, and code Playground
by Edward Tanguay
HTML
<div id="content"></div>
JavaScript
let html = "";
const customers = [
{
id: 1,
name: "Joe",
selected: false
},
{
id: 2,
name: "Hank",
selected: false
},
{
id: 3,
name: "Wanda",
selected: false
}
];
// NOTE: break not allowed with scores.forEach(function (score)
for(customer of customers) {
if(customer.id == 2) {
customer.selected = true;
break;
}
}
html += "<ul>";
for(customer of customers) {
html += "<li>" + customer.selected.toString() + '</li>';
}
html += "</ul>";
document.getElementById('content').innerHTML = html;