We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d6f7058 commit 28d4657Copy full SHA for 28d4657
src/underbar.js
@@ -654,6 +654,19 @@ var _ = {};
654
//
655
// Hint: Use Array.isArray to check if something is an array
656
_.flatten = function(nestedArray, result) {
657
+ var result=[];
658
+
659
+ var extractArray = function(arrays, result) {
660
+ _.each(arrays, function(arr) {
661
+ if (Array.isArray(arr)) {
662
+ extractArray(arr, result);
663
+ } else {
664
+ result.push(arr);
665
+ }
666
+ });
667
+ };
668
+ extractArray(nestedArray, result);
669
+ return result;
670
};
671
672
// Takes an arbitrary number of arrays and produces an array that contains
0 commit comments