I have this:
BasesFunctions.AllAgents = function(self){
self.agents = self.datas.reduce(function (all, item, index) {
item[self.valORname] == self.datas.valORname;
all.push(item[self.valORname]);
return all;
}, []);
};
My problem is simple this function return:
Array [ "BLABLA", "TEST", "HONORE", "SPONGEBOB", "PATRIC", "AVEA", "TEST", "HONORE", "PATRIC", "TEST", 16 more… ]
I want when my value exist to not push in my array, just a different value for index 1,2,3 ... . I don't want duplicate my value like that [ "BLABLA", "TEST", "HONORE", "SPONGEBOB", "PATRIC", "AVEA", "TEST", "HONORE", "PATRIC", "TEST", 16 more… ]
Can you help me ? plz Thanks
Thanks all i have the answer ^^ is very simple i just need to use IndexOf() like this :
BasesFunctions.AllAgents = function(self){
self.agents = self.datas.reduce(function (all, item, index) {
item[self.valORname] == self.datas.valORname;
if(all.indexOf(item[self.valORname]) === -1)
{
all.push(item[self.valORname]);
}
return all;
}, []);
};