I have a function that is returning an "Unexpected Token New" error at line 3. I am not sure why this is happening. It seems correct to me.
function flat_array(array){
var new = [];
for(var i = 0; i < array.length; i++)
{
new = new.concat(array[i]);
}
return new;
}
Array.flat()andArray.flatMap()are being implemented in modern browsers, so depending on which browsers you support, you might want to use the native.flat()method.