function arrayToCsv(data) {
data =
data.map((arr) => {
const newArr =
arr.map((el) => {
switch (typeof (el)) {
case (!'number' && !'string'): throw new Error('Unexpected value');
case 'string': el = el.replace(/"\w+"/g, match => "${match}");
if (/[,"]/.test(el)) return "${el}";
}
return el;
})
return newArr;
})
return data.join('\n');
}
Подскажите, почему у меня не выводит ошибку, если в data передаю function?