Hello guys, I'm trying to merge 2 arrays in one single sorted array, let me clarify it for you :
const PLAYERS = [
{ id: 1, name: 'Noob1', chatroom: [2, 3] },
{ id: 2, name: 'Noob2', chatroom: [4, 10] },
{ id: 3, name: 'Noob3', chatroom: [5] },
{ id: 4, name: 'Noob4', chatroom: [8, 6, 2, 7] },
{ id: 5, name: 'Noob5', chatroom: [9, 1, 4, 3, 11, 8, 6, 12] },
{ id: 6, name: 'Noob6', chatroom: [7, 10] },
{ id: 7, name: 'Noob7', chatroom: [8] },
{ id: 8, name: 'Noob8', chatroom: [3, 9] },
{ id: 9, name: 'Noob9', chatroom: [2, 6, 1, 7, 3, 4] },
{ id: 10, name: 'Noob10', chatroom: [5, 4] },
{ id: 11, name: 'Noob11', chatroom: [11] },
{ id: 12, name: 'Noob12', chatroom: [7, 4, 12] },
const ROOMS = [
{ id: 1, name: "ENG" },
{ id: 2, name: "DEU" },
{ id: 3, name: "ESP" },
{ id: 4, name: "CH" },
{ id: 5, name: "KR" },
{ id: 6, name: "JP" },
I'd like to have noob 1 in the ENG room, noob 2 in DEU etc etc. How would you do it ? Would you use spreead operator for that? Plus theres more indexes in my first array than my second one, so I assume I would use a filter method, right ?