Hello. I blunted :)

There is an array:

{ id: 1, questions: "Сколько у вас места?", options: [ { userPick: "Много", moveTo: 2 }, { userPick: "Немного есть", moveTo: 3 }, { userPick: "могу выделить угол в комнате", moveTo: 4 } ] } 

Mn need to get to userPick. It would be necessary forEach-it, but I do not understand how

  • There is an object, not an array. - Qwertiy
  • @Qwertiy, but it's just a data structure anyway - Bipa

2 answers 2

 var data = { id: 1, questions: "Сколько у вас места?", options: [ { userPick: "Много", moveTo: 2 }, { userPick: "Немного есть", moveTo: 3 }, { userPick: "могу выделить угол в комнате", moveTo: 4 } ] } for (var q=0; q<data.options.length; ++q) { console.log(data.options[q].userPick) } 

  • thanks a lot) - Bipa
  • @ Bipach, if this answer has solved your problem, you must accept it by clicking on the check mark to the left of it. - Qwertiy
  • I can’t accept the answer in 8 minutes :) - Bipa
  • @ Bipach, oh :) I quickly answered))) - Qwertiy
  var data = { id: 1, questions: "Сколько у вас места?", options: [ { userPick: "Много", moveTo: 2 }, { userPick: "Немного есть", moveTo: 3 }, { userPick: "могу выделить угол в комнате", moveTo: 4 } ] }; data.options.map((u) => console.log(u.userPick));