Format snippets
This commit is contained in:
@ -12,7 +12,11 @@ Flattens an array up to the specified depth.
|
||||
|
||||
```js
|
||||
const flatten = (arr, depth = 1) =>
|
||||
arr.reduce((a, v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []);
|
||||
arr.reduce(
|
||||
(a, v) =>
|
||||
a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v),
|
||||
[]
|
||||
);
|
||||
```
|
||||
|
||||
```js
|
||||
|
||||
Reference in New Issue
Block a user