Is there a way to split an array into multiple arrays based on specific elements from another array?
For example, take the following situation:
var test = ["1","2","3","env","6","7","8","uat","2344","wersdf","sdfs"];
var test2=["env","uat"];
In this case, we would like to create a mapping as follows:
{
env:["6","7","8"],
uat:["2344","wersdf","sdfs"]
}
It is important to note that the elements in test2 and test1 can vary. Additionally, the two values from test2 may not be consecutive in the test array; other items may be interspersed between them.