I want to add/remove an element to/from an array depending on an boolean value. This is what is working.
Is it possible to make this a bit shorter?
if (state === true) {
const index = array.indexOf(id)
if (index > -1)
array.splice(index, 1)
}
if (state === false) {
const index = array.indexOf(id)
if (index === -1)
array.push(id)
}