From ad5e844cb518be90efecfa2473cc61f16db083d2 Mon Sep 17 00:00:00 2001 From: Nikolai Kiselev Date: Thu, 21 Mar 2019 13:54:12 +0400 Subject: [PATCH] Add another solution (#35644) --- .../steamroller/index.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/guide/english/certifications/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller/index.md b/guide/english/certifications/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller/index.md index b105d08d2f..d488c4e21c 100644 --- a/guide/english/certifications/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller/index.md +++ b/guide/english/certifications/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller/index.md @@ -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.