Course · Section 9: Data Structures, Modern Operators and Strings · Lecture 111: The Spread Operator (...)
Implement `toggleInArray(list, value)` returning a new array with `value` removed if present, or added if absent (useful for multi-select state).
+ 1 hidden test run on Submit.
This is the pattern behind toggling a checkbox in a set of selected ids. If the value is already in the array you remove it with filter; otherwise you add it with spread. Either branch returns a new array.
Run your code to see results.