I like the refactor in general, but I'm not 100% sure I'm on board with the joinStrings function as opposed to a .join().filter() in each switch case. Seems like maybe more a case of abstraction for abstraction's sake than valuable code reuse.
I'd also maybe prefer a more explicit null check (still using the filter method) for clarity sake. But that may be just be preference.
All that aside, the simplification from all the conditional checks and concatenations to a single join and filter of an array is spot on. 👍
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I like the refactor in general, but I'm not 100% sure I'm on board with the joinStrings function as opposed to a .join().filter() in each switch case. Seems like maybe more a case of abstraction for abstraction's sake than valuable code reuse.
I'd also maybe prefer a more explicit null check (still using the filter method) for clarity sake. But that may be just be preference.
All that aside, the simplification from all the conditional checks and concatenations to a single join and filter of an array is spot on. 👍