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 for programmers to stay up-to-date, learn new skills, and share ideas.
We’ll never post without your permission.