Currently, I have an array of objects set up like this:
https://i.sstatic.net/l6d3z.png
My goal is to loop through the array and extract users based on a specific roomCode
So, I've attempted two different approaches:
for(let i=0; i <data.liveRooms.length; i++) {
if(data.liveRooms[i].roomCode === code) {
this.usersLive = data.liveRooms[i].users;
}
}
And then I tried another method as follows:
for(let i=0; i <data.liveRooms.length; i++) {
this.liveDataDictionary[data.liveRooms[i].roomCode] =
data.liveRooms[i].users;
}
this.usersLive = this.liveDataDictionary[code];
Unfortunately, none of these techniques seem to be doing what I want them to do, but I'm not sure why. Could someone please help me figure this out?