how to remove value contain comma in array?
const dataSize = ['XL', 'M,L,XL', 'S', 'X,L']
I tried to use the foreach or map then use the indexOf.
dataSize.map((x) => {
if(x.indexOf >-1 !== true) {
return x;
}
});
but the output is like this ['XL', undefined, 'S', undefined] instead of ['XL', 'S']
>Solution :
const dataSize = ["XL", "M,L,XL", "S", "X,L"];
console.log(dataSize.filter((s) => !s.includes(",")));