Best way to toggle a property in an array
This could be accomplished via an XOR,  or boolean not equal in other words.


const people = [
  {
    "name": "Olivia",
    "lead": true
  },
  {
    "name": "Gary",
    "lead": false
  },
  {
    "name": "Adam",
    "lead": false
  }
]

const toggleLead = (name) =&gt;
    [...people].map(person =&gt;
        ({
            ...person,
            lead: person.lead !== (person.name===name)
        })
    )

console.log(toggleLead('Gary'))
.as-console-wrapper { max-height: 100% !important; top: 0; }