Hang and Hack
Pages
Home
Links
Arrays
Monday, June 13, 2016
Flatten an array using an Underscore function
This Underscore function also has a native version, you can use either.
Take an array such as this one:
var arrays = [[1, 2, 3], 8,[4, 5], [6]];
and flatten it so that it looks like this:
[1, 2, 3, 8, 4, 5, 6];
Hint in the comments.
1 comment:
Unknown
June 13, 2016 at 8:52 AM
The big hint? Use reduce.
Need another hint? concat is awesome
Reply
Delete
Replies
Reply
Add comment
Load more...
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
The big hint? Use reduce.
ReplyDeleteNeed another hint? concat is awesome