Last active
September 16, 2016 21:37
-
-
Save samguergen/c2c4504a1a394c45fb9cf7bd7c07f26c to your computer and use it in GitHub Desktop.
manual array flatten function
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 flattenIt(arr){ | |
var str = arr.toString(); | |
str.replace('[','').replace(']',''); | |
var flatArr = str.split(','); | |
var numArr = flatArr.map(Number); | |
return numArr; | |
} | |
flattenIt([[1,2,[3]],4]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment