Created
April 7, 2017 01:24
-
-
Save anonymous/92822a0c97040641ecfb145cb091d1f7 to your computer and use it in GitHub Desktop.
4.4 Array Flattener created by smillaraaq - https://repl.it/GzQT/1
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(argArray){ | |
| var newArray=[]; | |
| for(i=0;i<argArray.length;i++){ | |
| if(typeof argArray[i]==="object"){ | |
| for(x=0;x<argArray[i].length;x++){ | |
| newArray.push(argArray[i][x]); | |
| } | |
| }else{ | |
| newArray.push(argArray[i]); | |
| } | |
| } | |
| console.log(newArray); | |
| } | |
| flatten([1,[2,3],4]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment