-
-
Save AliceWonderland/2c22a33b2e1e7db7c61f6a9ebc185e4e 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