0

console.log(participants); results in:

enter image description here

I am trying to access the firstName of each "participant":

const entries = Object.entries(participants);

entries.map((participant) => {
  console.log(participant.firstName);
});

Do you see what I am doing wrong here?

Joey Coder
  • 2,325
  • 3
  • 13
  • 37
  • see this hope this will hep https://stackoverflow.com/questions/18910939/how-to-get-json-key-and-value-in-javascript – Umair Mubeen Oct 24 '20 at 13:18
  • Consider reading the basic docs related to javascript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries – kind user Oct 24 '20 at 13:19
  • Apply map directly on participants array list. participants.map(x=> console.log(x.firstName)); – Vimal Patel Oct 24 '20 at 13:21
  • @VimalPatel thanks for the suggestion, however that returns `participants.map is not a function`. I feel like I tried a kind of combinations but will go through the readings now. – Joey Coder Oct 24 '20 at 13:24
  • 1
    I was about to submit an answer when the question was closed. Anyways, don't use Object.entries() and apply the map like this: participants.Pm2bnmV.map(participant => console.log(participant.firstName)); Because it looks like the participants variable has a property that has the array. If change that structure so the participants variable is just an array you can do what Vimal Patel said. – Dillan Wilding Oct 24 '20 at 13:24
  • Thanks, Dillan. That solved it. – Joey Coder Oct 24 '20 at 15:56

0 Answers0