Skip to content

Instantly share code, notes, and snippets.

@abo-elleef
Created April 6, 2017 07:10
Show Gist options
  • Save abo-elleef/1900410daf34f7b1ca2fcd4118dbdae6 to your computer and use it in GitHub Desktop.
Save abo-elleef/1900410daf34f7b1ca2fcd4118dbdae6 to your computer and use it in GitHub Desktop.
flatten#js
function flatten(set, seen){
var seen = seen ? seen : [];
for(var i=0; i<set.length; i++){
if(Array.isArray(set[i])){
flatten(set[i],seen)
}else{
seen.push(set[i])
}
}
return seen;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment