Toggle an array value by adding it to the array when it is not present, and removing from the array it when it is present. Done using Ramda.js.

const items = ['a', 'b', 'c', 'd', 'e'];
const toggleValue = ifElse(
  contains(__, items),
  without(__, items),
  append(__, items)
);

toggleValue('f');
    ["a", "b", "c", "d", "e", "f"]

toggleValue('a');
    ["b", "c", "d", "e"]

Example