I am receiving an Array ( div
) with a single String and I want it to print the following A,B,C,D
, that is, to convert that String into several strings within the array and then order it and remove duplicates.
Array.prototype.unique=function(a){
return function(){return this.filter(a)}}(function(a,b,c){return
c.indexOf(a,b+1)<0;
});
var div = ["'D','B,'C','A','B'"];
var f = div.join();//.unique().sort().join().slice(0, -1);
var filtroDiv = [f.slice(0, -1)];
console.log(filtroDiv); //["'A','B,'C','D','B"]
You can do it this way:
I hope this answer is more correct and can help you. I add an image so you can see the result of the code.