I have an array as below
var abc = [11,2,11,3,11,4,9,5]
I am actually appending the data into datatables, and it would be like this as of now
11|2
11|3
11|4
9 |5
So my question is, i want it to check if there is a duplicate/same value in index 0, and add everything in index 1, example as below
11|9
9 |5
Is is possible for me to do that? I have tried the below but still not working
for (var a = 0; a < x.length; a++) {
if (x[0] !== -1){
alert(x[0]);
} else {
console.log("no same value found");
}
}
But still no luck making it to work. Appreciate any help that i can get.
Thanks