Skip to content

Instantly share code, notes, and snippets.

@jamlfy
Created January 27, 2015 20:41
Show Gist options
  • Select an option

  • Save jamlfy/80bbe3a3966b0a140a2a to your computer and use it in GitHub Desktop.

Select an option

Save jamlfy/80bbe3a3966b0a140a2a to your computer and use it in GitHub Desktop.
function fal (input) {
var output = [], value;
for (var i = input.length - 1; i >= 0; i--) {
if (Array.isArray(input[i]) && input[i].length > 0) {
value = fal(input[i]);
for (var f = 0; f < value.length; f++)
output.push(value[f]);
} else if( !Array.isArray(input[i]) ){
output.push(input[i]);
}
};
return output;
}
module.exports = function () {
var arr = [];
for (arg in arguments)
arr.push(arguments[arg]);
return fal(arr).reverse();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment