I am checking for undefined
and want to replace with ""
I have:
let values = [ ['header1','header2'],
['AAA', undefined],
[2, 'BB'],
[undefined, 'CCC'],
['AAA', 4],
];
values.forEach(function (row) {
row.forEach(function(col) {
col= col===undefined ? "":col;
});
});
It returns the original array values.
But I am expecting
[ ['header1','header2'],
['AAA', ""],
[2, 'BB'],
["", 'CCC'],
['AAA', 4],
];
What am I doing wrong?