Created
January 20, 2023 17:04
-
-
Save razouck/017ab1d9eb0cb6bb2ad3d31ab080766d to your computer and use it in GitHub Desktop.
idk
This file contains 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
let a = [1, 2, [3, [4, [5, [6], [7, [8]]]]]]; | |
function brainDeadDeepFlat(arr) | |
{ | |
return Array.isArray(arr) | |
? arr.reduce( (arr, e) => arr.concat(brainDeadDeepFlat(e)), [] ) | |
: [arr]; | |
} | |
function normalBrainDeepFlat(arr) | |
{ | |
return arr.some(e => Array.isArray(e)) | |
? bigBrainDeepFlat(arr.flat()) | |
: arr; | |
} | |
function galaxyBrainDeepFlat(arr) | |
{ | |
return arr.flat(Number.MAX_VALUE); | |
} | |
function transcedentalBrainDeepFlat(arr) | |
{ | |
return arr.toString().split(',').map(e => +e); | |
} | |
console.log(transcedentalBrainDeepFlat(a)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment