StefiIOE

[NWD]prv kolokvium 2018 zadaca 2

Nov 24th, 2020 (edited)
846
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const array = [1, 2, [3, 4, [5, 6]]];
  2. function deep_flatten(array){
  3.   return array.reduce(function(flat,toFlatten){
  4.     return flat.concat(Array.isArray(toFlatten)? deep_flatten(toFlatten) : toFlatten);
  5.    },[] )
  6.    }
  7.   console.log(deep_flatten(array));
Add Comment
Please, Sign In to add comment