Hi i have this example:
let list = [{dog,1}, {dog,2}, {cat,1}, {cat,3}]
And i want this result:
let result= [
[{dog,1}, {cat,1}],
[{dog,2}],
[{cat,3}]]
I could do this with two different for-loops: first sorting by number, then creating a new array if the number changes in the second for-loop.
But i guess there will be a better solution but i’m not really familiar with JavaScript.
Maybe like .map() or .filter()?