I found this answer on how to map over an array to create ids Add id to array of objects - Javascript for each object in the array, but I was wondering how you'd adapt this code to create a sequence of ids for every group of another value:
let dataset = [
{value: "a"},
{value: "a"},
{value: "a"},
{value: "b"},
{value: "b"},
{value: "c"},
]
becomes:
[
{value: "a", groupid: 1},
{value: "a", groupid: 2},
{value: "a", groupid: 3},
{value: "b", groupid: 1},
{value: "b", groupid: 2},
{value: "c", groupid: 1},
]
Any help appreciated!