For instance, we write
const names = options.flatMap((o) => (o.assigned ? [o.name] : ));
options.flatMap with a callback that checks if
o.assigned is set.
If it is, then we array with
Otherwise, we return an empty array.
And we use
flatMap to combine them into one flattened array.