'Listing one array next to another in one message
I have two arrays and I want to list in one entry of Array 1 next to an entry from Array 2.
My two Arrays are named memberIDs and rolesIDs. Whereas memberIDs contains the IDs from member in a voice Channel, roleIDs lists a ton of IDs from different roles.
To list them next to each other I made the following code:
message.channel.send(memberIDs.map(element => "<@" + element + "> -> " + rolesIG.map(element => "<@&" + element + ">" ).join()).join("\n"));
Sadly it isn't working like I want it to, although it lists all member seperatly, on the other site it lists all entrys from roleIDs like this:
<@memberID1> -> <@&roleID1> <@&roleID2> <@&roleID3>
<@memberID2> -> <@&roleID1> <@&roleID2> <@&roleID3>
It want it to behave like this:
<@memberID1> -> <@roleID1>
<@memberID2> -> <@roleID2>
I apprectiate any help.
Solution 1:[1]
You could do something like:
var outarr = []
for(var i = 0; i < memberIDs.length; i++) {
outarr[i] = `<@${memberIDs[i]}> -> <@${rolesIG[i]}>`
}
now outarr is a list, where each item contains the member ID concatenated with the roleIG
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | quandale dingle |
