(list: T[], item: T)
| 11 | } |
| 12 | |
| 13 | export function toggleListItem<T>(list: T[], item: T): T[] { |
| 14 | const itemIndex = list.indexOf(item) |
| 15 | if (itemIndex === -1) { |
| 16 | return list.concat(item) |
| 17 | } else { |
| 18 | const newList = [...list] |
| 19 | newList.splice(itemIndex, 1) |
| 20 | return newList |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | export function shuffle(arr) { |
| 25 | let i = arr.length |