I am trying to add functionality into my JS script that de-duplicates the values returned. My original script here:
try{
var productList = dataLayer.basket.products.map(function(product) {
    return product.travelType;
});
return productList.join('|');
  }
catch(err){}which returns values from an array like Bus|Bus|Train|Car|Bus 
What I am trying to get to is an additional part of the script that would clean those values and de-duplicate them. For example the above script would only show "bus" once e.g. Bus|Train|Car
I have tried to do this using a filter but I am getting a null value being returned:
try{
var productList = dataLayer.basket.products.map(function(product) {
    return product.travelType;
});
  
var filteredArray = productList.filter(function(item, pos){
    return productList.indexOf(item)=== pos;
  });
  
return filteredArray.join('|');
  }
catch(err){}Any guidance would be gratefully appreciated.
Thanks, M
 
     
     
     
     
    