I have the following array named parsedAutor
and I need to remove the empty elements from the nested arrays.
[
['John Doe', '', 'CPF 000.000.000-00'],
['30/05/2018 - Vara de Delitos de Roubo e Extorsão'],
['John Doe', '', 'CPF 000.000.000-00'],
['29/02/2016 - 1ª Vara Criminal'],
['John Doe', '', 'CPF 000.000.000-00'],
['18/02/2016 - 3º Juizado Especial Cível'],
['John Doe', '', 'CPF 000.000.000-00'],
['18/02/2016 - 3º Juizado Especial Cível']
]
How do I manage to do it? I've been trying to map the elements and then filter them, but it's not working and I think I'm doing it wrong.
Here's what I've been trying to do.
const autor = $('div[class="espacamentoLinhas"]').toArray();
let parsedAutor = autor.map((x) => x.children[2].data.trim());
console.log(parsedAutor);
parsedAutor = parsedAutor.map((x) => x.split('\n').map((y) => y.trim()));
console.log(parsedAutor);
// note that the code above is just to get the context from where I taking the values, please focus on the code below
const filteredAutor = parsedAutor.map((x) => {
x.filter((y) => y !== '');
});
console.log(filteredAutor);
But it returns me eight undefined
values, what am I doing wrong?
Thanks in advance.