Skip to content

Instantly share code, notes, and snippets.

@yitonghe00
Created April 17, 2020 05:10
Show Gist options
  • Save yitonghe00/aceb04e709273a74ed18bbf8b8cc29bc to your computer and use it in GitHub Desktop.
Save yitonghe00/aceb04e709273a74ed18bbf8b8cc29bc to your computer and use it in GitHub Desktop.
let arrays = [[1, 2, 3], [4, 5], [6]];
// Your code here.
const flat = (arrays) => {
const ret = [];
arrays.forEach((array) => {
array.forEach((num) => ret.push(num));
});
return ret;
};
console.log(flat(arrays));
// → [1, 2, 3, 4, 5, 6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment