I'm pretty new to AppScript and I have absolutely no idea how to manipulate arrays. I just want to be able to take one array and collapse the common elements in a separate array as follows;
groceryArray = [
["fruit", "apple"],
["fruit", "banana"],
["veg", "potato"],
["veg", "onion"],
["veg", "broccoli"],
]
and turn that into this...
groceryArray2 = [
["fruit", ["apple", "banana"]],
["veg", ["potato", "onion", "broccoli"]],
]
I would of thought it's fairly straightforward but I can't work it out at all...