CHALLENGE
const arr = [1, [2, 3], [4, [5, 6]]];
const a = arr.flat();
const b = arr.flat(Infinity);
const c = arr.flatMap(x => Array.isArray(x) ? x : [x, x]);
console.log(a, b, c);
❤2
What is the output?
Anonymous Quiz
24%
[ 1, 2, 3, 4, [ 5, 6 ] ] [ 1, 2, 3, 4, 5, 6 ] [ [1,1], [2,3], [4,[5,6]] ]
37%
[ 1, 2, 3, 4, [ 5, 6 ] ] [ 1, 2, 3, 4, 5, 6 ] [ 1, 1, 2, 3, 4, [ 5, 6 ] ]
24%
[ 1, 2, 3, 4, [ 5, 6 ] ] [ 1, 2, 3, 4, 5, 6 ] [ 1, 2, 3, 4, [ 5, 6 ] ]
15%
[ 1, 2, 3, 4, 5, 6 ] [ 1, 2, 3, 4, 5, 6 ] [ 1, 1, 2, 3, 4, [ 5, 6 ] ]