5 kyu
flatten()
2,884 of 4,573jhoffner
Description:
For this exercise you will create a global flatten method. The method takes in any number of arguments and flattens them into a single array. If any of the arguments passed in are an array then the individual objects within the array will be flattened so that they exist at the same level as the other arguments. Any nested arrays, no matter how deep, should be flattened into the single array result.
The following are examples of how this function would be used and what the expected results would be:
flatten(1, [2, 3], 4, 5, [6, [7]]) // returns [1, 2, 3, 4, 5, 6, 7]
flatten('a', ['b', 2], 3, null, [[4], ['c']]) // returns ['a', 'b', 2, 3, null, 4, 'c']
Arrays
Algorithms
Similar Kata:
Stats:
Created | Mar 12, 2013 |
Published | Mar 16, 2013 |
Warriors Trained | 9663 |
Total Skips | 1483 |
Total Code Submissions | 36159 |
Total Times Completed | 4573 |
JavaScript Completions | 2884 |
CoffeeScript Completions | 131 |
Python Completions | 1628 |
Total Stars | 174 |
% of votes with a positive feedback rating | 90% of 578 |
Total "Very Satisfied" Votes | 487 |
Total "Somewhat Satisfied" Votes | 72 |
Total "Not Satisfied" Votes | 19 |