Advertisement
Guest User

Untitled

a guest
May 19th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.19 KB | None | 0 0
  1. function flatten(arr) {
  2. if (Array.isArray(arr)) {
  3. return arr.reduce(function(done,curr){
  4. return done.concat(flatten(curr));
  5. }, []);
  6. } else {
  7. return arr;
  8. }
  9. }
  10.  
  11. // [ 1, 2, 3, 4 ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement