Right now, if 'Everything' in the list is detected, the output becomes [""].
Expected output: []
Copy.names = rule.names.map(function(x) {
if (x.name ==='Everything') {
return '';
} else {
return x.name;
}
});
return;
Also, consider using Array.prototype.filter for this. – Lutzfilter
.map
returns an element for every element you iterate over. – Thornmap
tofilter
,return ''
tofalse
andreturn x.name
totrue
– Scenographyreturn x.name === 'Everything'
instead of the whole if...else – Scenography