Update Array with value provided. Remove if exists - add if not
export const updateArrayWithValue = (arr, val) => {
let result = [];
let inArray = false;
arr.forEach((item, i) => {
if (item === val) {
inArray = true;
} else {
result.push(item);
}
});
if (!inArray) {
result.push(val);
}
return result;
}