Guest User

Untitled

a guest
Jan 23rd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. const flatten = function(arr, res = []) {
  2. for (let n = 0, length = arr.length; n < length; n++) {
  3. const value = arr[n];
  4. if (Array.isArray(value)) {
  5. flatten(value, res);
  6. } else {
  7. res.push(value);
  8. }
  9. }
  10. return res;
  11. };
Add Comment
Please, Sign In to add comment