0

I have the following array of objects:

participantIdentities: Array(2)
    0:
        participantId: 1
        player: Object
            accountId: (...)
            summonerName: "test1"
    1:
        participantId: 2
        player: Object
            accountId: (...)
            summonerName: "test2"

I am trying to figure out how to return the object whose player object property summonerName is "test1". Sadly I can't quite figure it out. I tried using find() but I haven't had much success so far. I assume I'm doing something wrong.

let participants = match.details.participantIdentities;
participants.find(([key,value]) => value.key === "test1");
halfer
  • 19,824
  • 17
  • 99
  • 186
Onyx
  • 5,186
  • 8
  • 39
  • 86
  • `const entry = participants.find(({player}) => player.summonerName === "test1");` or even `const entry = participants.find(({player: {summonerName}}) => summonerName === "test1");` https://jsfiddle.net/tjcrowder/tp5cLrjk/ `find` passes each object in the array to you, not an array of key/value pairs. – T.J. Crowder Jul 06 '19 at 16:31
  • participantIndetitities.find(({player}) => player.summonerName === 'test1) – F.bernal Jul 06 '19 at 16:31

0 Answers0