Skip to content

Instantly share code, notes, and snippets.

@NhanKhangg98
Last active November 6, 2022 09:38
Show Gist options
  • Save NhanKhangg98/84ded68f733572e218d2f5d7b68cabe3 to your computer and use it in GitHub Desktop.
Save NhanKhangg98/84ded68f733572e218d2f5d7b68cabe3 to your computer and use it in GitHub Desktop.
function flatten(nums) {
const arr = [];
nums.forEach((num: Number[]) => {
if (Array.isArray(num)) {
arr.push(...flatten(num));
} else {
arr.push(num);
}
});
return arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment