It is interesting! There are a few points about your solution:
If I were going to define flatten with reduce, I would have written something like the following:
if(xs.length === 0) return ;
return xs.reduce((acc, x) => [...acc, ...(Array.isArray(x)? flatten(x):
We’re a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.