My question couldn't fit in the title, so here it is.
Currently, I have a loop that generates a div element for each match, and within that div, I want to display the information of ONE of the 10 match participants. To achieve this, I am using a function that returns the object of a participant with a specific name. However, as shown below, every time I need to access a property of that participant, I have to repeatedly call the function.
I don't believe this is the most efficient approach, right? My front-end framework of choice is Vue.js.
The code I currently have is as follows:
Loop:
<div v-for='match in summonerMatches.matches'>
{{ findParticipant(match).championId }}
{{ findParticipant(match).spell1Id }}
{{ findParticipant(match).spell12d }}
</div>
Function:
findParticipant(match){
let participantId = match.details.participantIdentities.find(x => x.player.summonerName === this.summonerInfo.name).participantId;
let participant = match.details.participants.find(x => x.participantId === participantId)
return participant
}
If this function was not inside a loop, I could simply store the participant object and then utilize it. However, since it's within a loop, I'm unsure how to go about achieving this more efficiently.