i'm new to react and javascript and i have some difficulties coping with a task. Let's get started. I have and array like this: clients = ["Alex", "Jimmy"] and then i create another array with the following way:
for (var i = 0; i < clients.length; i++) {
var portf = Object.keys(obj.portfolios);
}
As a result for every i a portf array is created with the following values: For i = 0 portf = 1,2,3 and for i = 1 portf = 4,5,6 I want to create and array of objects with the following format using iteration:
var ops = [{
label: "Alex",
options: [
{value: 1},
{value: 2},
{value: 3}
],
label: 'Jimmy',
options: [
{value: 4},
{value: 5},
{value: 6}
]
Do you know how to do this?
Object.keys(obj.portfolios)is going to be the same for everyi. How do you get1,2,3and4,5,6?