Open this example in the interactive library
Source code
const rows = [
{ row: "A", seat: 1, held: true },
{ row: "A", seat: 2, held: false },
{ row: "B", seat: 1, held: false },
{ row: "B", seat: 2, held: false },
];
const result = rows.map((r) =>
r.row === "B" && r.seat === 1 ? { ...r, held: true } : r,
);
console.log(JSON.stringify(result, null, 2));
Sample output
[
{
"row": "A",
"seat": 1,
"held": true
},
{
"row": "A",
"seat": 2,
"held": false
},
{
"row": "B",
"seat": 1,
"held": true
},
{
"row": "B",
"seat": 2,
"held": false
}
]