I have an JS Object that is built up as followed props.moves:
0: {userId: 168, moveId: 198, moveName: "FirstSettlementMove", building: {…}}
1: {userId: 168, moveId: 200, moveName: "FirstSettlementMove", building: {…}}
2: {userId: 168, moveId: 202, moveName: "FirstSettlementMove", building: {…}}
3: {userId: 168, moveId: 204, moveName: "FirstSettlementMove", building: {…}}
4: {userId: 168, moveId: 206, moveName: "FirstSettlementMove", building: {…}}
I want to write a specific function that goes through all elements of this object so starting from 0 to the last one. And with that it should check for the value in moveName and put all unique ones into an array and return that array. So basically something like:
function moveCollector(props.moves) {
let arr = [];
for (key=="moveName" in props.moves)
add every unique value to arr
}
Has anyone an approach or solution for that? I am especially clueless about the part with the unique values and the fact that one object element has various keys.
Thanks in advance!