Pages

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:

  1. The big hint? Use reduce.

    Need another hint? concat is awesome

    ReplyDelete