I'm trying to remove part of the value of an element in an array after '_' and once its done remove all repeated elements.
Array looks like
names = ["ann_w", "james_q", "ann_q", "peter_p", "steve_q", "james_s"];
And I am trying to convert it into
names = ["ann", "james", "peter", "steve"];
Below code is returning undefined and cant figure it out how to remove all repeated elements.
for (i = 0; i < names.length; i++) {
names[i] = names[i].substring(names[i].indexOf("_") + 1);
}