I'm trying to turn a list into a list of lists. In this case I have a list similar to the following: a = [ 1, 1, 1, 2, 3, 3] and I would like to separate the same items for another list, like: a = [[1, 1, 1] ; [2] ; [3, 3]]
let b = this.a.filter((element, index) => {
return this.a.indexOf(element) === index;
});
I tried using splice and filter, but without success. I was only able to create a list with different values... b=[1,2,3] Is there any solution?