Last active
November 6, 2022 09:38
-
-
Save NhanKhangg98/84ded68f733572e218d2f5d7b68cabe3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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