I am trying to get the unique data out of the rows.
My data
name title
tim 1
tim 1
tim 2
tim 3
time 3
jenny 5
jenny 5
jenny 6
jenny 7
My goal is to display my table using javascript to show
tim 1
tim 2
time 3
jenny 5
jenny 6
jenny 7
I know it's easy to change the data structure or the way to select the data but I don't have the access to the DB so I need to figure out in the javascript
my first step is to push all the unique title to my peopleArray:
1
2
3
5
6
7
The codes I have tried.
for(var a=0; a<results.length; a++){
if(results[(a+1)]){
if(a==0 || results[a].title != results[(a+1)].title){
peopleArray.push(results[(a)].title)
}
}
}
My codes don't really work and I am stocked here. Anyone has tips for this? Thanks a lot!