i have question about array, for example i have an array of object, like this
const data = [
{
level: 1,
name: "Naruto",
},
{
level: 2,
name: "Dragon",
},
{
level: 2,
name: "Ball",
},
{
level: 3,
name: "Sasuke",
},
]
Now i want to create new array base on level , mean that after format it will look like this:
[
[
{
name: "naruto"
}
],
[
{
name: "Ball"
},
{ name: "Dragon" }
],
[
{name:"Sasuke"}
]
];
How can i do this, thanks you guys
groupBycommands in javascript, they are going to give similar results, which you can manipulate into your answer.groupByto the result that you require