I need to remove the empty string from the array inside another array and I need to return the whole array without an empty string, can anyone help me with this, array is below
const testArr = [
{
code: 'size',
name: 'Size',
options: ['small', "", "", "large"],
},
{
code: 'color',
name: 'COlor',
options: ['black', "", "", "red"],
},
]
I need result like this(without empty string)
[
{
code: 'size',
name: 'Size',
options: ['small', "large"],
},
{
code: 'color',
name: 'COlor',
options: ['black', "red"],
},
]
.filter()method to filter out the empty strings:array.filter(s => s.trim().length > 0).filter()is returning only options, I need a whole array without empty string @Yousaf