Add another solution (#35644)

This commit is contained in:
Nikolai Kiselev
2019-03-21 13:54:12 +04:00
committed by The Coding Aviator
parent 739f4a8850
commit ad5e844cb5

View File

@ -148,6 +148,15 @@ You will definitely need recursion or another way to go beyond two level arrays
* We replace the double comma with one, then split it back into an array.
* map through the array and fix object values and convert string numbers to regular numbers.
## ![:rotating_light:](https://forum.freecodecamp.com/images/emoji/emoji_one/rotating_light.png?v=3 ":rotating_light:") Advanced Code Solution 2:
const steamrollArray = arr => arr.flat(Infinity);
### Code Explanation:
* Use `Array.flat()` to flatten an array with `Infinity` as a parameter for the depth.
## ![:clipboard:](https://forum.freecodecamp.com/images/emoji/emoji_one/clipboard.png?v=3 ":clipboard:") NOTES FOR CONTRIBUTIONS:
* ![:warning:](https://forum.freecodecamp.com/images/emoji/emoji_one/warning.png?v=3 ":warning:") **DO NOT** add solutions that are similar to any existing solutions. If you think it is **_similar but better_**, then try to merge (or replace) the existing similar solution.