diff --git a/3.implement-Array.prototype.flat.md b/3.implement-Array.prototype.flat.md index 7710a02..eff5fd3 100644 --- a/3.implement-Array.prototype.flat.md +++ b/3.implement-Array.prototype.flat.md @@ -15,19 +15,11 @@ Could you manage to implement your own one? Here is an example to illustrate ```js -const arr = [1, [2], [3, [4]]]; - -flat(arr); -// [1, 2, 3, [4]] - -flat(arr, 1); -// [1, 2, 3, [4]] - -flat(arr, 2); -// [1, 2, 3, 4] - -flat(arr, Infinity); -// [1, 2, 3, 4] +console.log(flat([1, [2, [3, [4, [5]]]]], 1)); // [1, 2, [3, [4, [5]]] +console.log(flat([1, [2, [3, [4, [5]]]]], 2)); // [1, 2, 3, [4, [5]] +console.log(flat([1, [2, [3, [4, [5]]]]], 3)); // [1, 2, 3, 4, [5] +console.log(flat([1, [2, [3, [4, [5]]]]], 4)); // [1, 2, 3, 4, 5] +console.log(flat([1, 2, 3, [4, 5, [6, 7, 8, [9, 10]]]], Infinity)) // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ``` follow up