Test case details Title *
Description (Markdown syntax is allowed)
Test cases
Test #1 Title *
Async
Code * const bad1a = nums.reduce ((acc, row ) => [...acc, ...row], []);
Test #2 Title *
Async
Code * const bad1b = nums.reduce ((acc, row ) => {
row.forEach (el => acc.push (el));
return acc;
}, []);
Title *
Async
Code * const bad1c = nums.reduce ((acc, row ) => {
acc.push (...row);
return acc;
}, []);
Title *
Async
Code * let bad2a = [];
nums.forEach ((arr ) => bad2a = bad2a.concat (arr));
Title *
Async
Code * let bad2b = [];
for (let row = 0 ; row < nums.length ; row++) {
bad2b = bad2b.concat (nums[row]);
}
Title *
Async
Code * const bad3 = JSON .parse ("[" + JSON .stringify (nums).replace (/\[|\]/g , "" ) + "]" );
Title *
Async
Code * const good1a = nums.flat ();
Title *
Async
Code * const good1b = nums.flatMap (row => row);
Title *
Async
Code * const good2a = [];
nums.forEach ((arr ) => good2a.push (...arr));
Title *
Async
Code * const good2b = [];
for (let row = 0 ; row < nums.length ; row++) {
good2b.push (...nums[row]);
}
Title *
Async
Code * const good3a = [];
for (let row = 0 ; row < nums.length ; row++) {
for (let col = 0 ; col < nums[0 ].length ; col++) {
good3a.push (nums[row][col]);
}
}
Title *
Async
Code * const good3b = new Array (nums.length * nums[0 ].length );
let ind = 0 ;
for (let row = 0 ; row < nums.length ; row++) {
for (let col = 0 ; col < nums[0 ].length ; col++) {
good3b[ind] = nums[row][col];
ind++
}
}
Title *
Async
Code * const good4a = [].concat .apply ([], nums);
Title *
Async
Code * const good4b = [].concat (...nums);
Title *
Async
Code * const good4c = Array .prototype .concat .call ([], ...nums);
Title *
Async
Code * const good5 = [];
nums.forEach (row => Array .prototype .push .apply (good5, row));