{"ScriptPreparationCode":null,"TestCases":[{"Name":"INFINITY","Code":"function flattenAnyArray2(nestedArr) {\r\n return nestedArr.flat(Infinity);\r\n}\r\n\r\nconst result2 = flattenAnyArray2([\r\n 1,\r\n [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12, [13, [14, [15, [16, [17, [18, [19, [20]]]]]]]]]]]]]]]]]]],\r\n]);","IsDeferred":false},{"Name":"RECURSION","Code":"function flattenAnyArray(nestedArr) {\r\n const flattenedArr = [];\r\n function flattenHelper(subArr) {\r\n for (const el of subArr) {\r\n if (Array.isArray(el)) {\r\n flattenHelper(el);\r\n } else {\r\n flattenedArr.push(el);\r\n }\r\n }\r\n }\r\n flattenHelper(nestedArr);\r\n return flattenedArr;\r\n}\r\n\r\nconst result1 = flattenAnyArray([\r\n 1,\r\n [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12, [13, [14, [15, [16, [17, [18, [19, [20]]]]]]]]]]]]]]]]]]],\r\n]);","IsDeferred":false}]}