I have two arrays that look like this:
const players = ["id1", "id2", "id3", "id4"]
const games = ["gid1", "gid2"]
I need to return an array that looks like this:
const newArray = [
{playerId: "id1", gameId: "gid1"}, {playerId: "id1", gameId: "gid2"},
{playerId: "id2", gameId: "gid1"}, {playerId: "id2", gameId: "gid2"},
{playerId: "id3", gameId: "gid1"}, {playerId: "id3", gameId: "gid2"},
{playerId: "id4", gameId: "gid1"}, {playerId: "id4", gameId: "gid2"}
]
What's the best way to achieve this? I have been trying a combination of map and reduce, but can't seem to figure it out.