Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const flatten = function(arr, res = []) {
- for (let n = 0, length = arr.length; n < length; n++) {
- const value = arr[n];
- if (Array.isArray(value)) {
- flatten(value, res);
- } else {
- res.push(value);
- }
- }
- return res;
- };
Add Comment
Please, Sign In to add comment