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.filter.mapreturns an element for every element you iterate over.maptofilter,return ''tofalseandreturn x.nametotruereturn x.name === 'Everything'instead of the whole if...else