Skip to content

Instantly share code, notes, and snippets.

@Shahor Shahor/pr.js
Last active Aug 29, 2015

What would you like to do?
write a function that takes an array as input that can contain both ints and more arrays (which can also contain an array or int) and return the flattened array.
function flatten(input) {
var ret = []
input.forEach(function (inp) {
ret = ret.concat(Array.isArray(inp) ? flatten(inp) : inp)
return ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.