N
N
Nikolay Semenov2017-08-23 09:31:09
JavaScript
Nikolay Semenov, 2017-08-23 09:31:09

Is it possible to concatenate an array with an object? What to do for this?

Guys, hello everyone.
Tell me if it is possible somehow in an array of this kind

datas': [{label: 'Я ищу', value: 'Девушку'}, {label: 'Цели знакомства', value: ['поиск друзей', 'флирт', 'любовь']}, {label: 'Семейное пложение', value: 'холост'}, {label: 'Сексуальная ориентация', value: 'Гетеро'}, {label: 'Рост', value: '178 см'}, {label: 'Цвет волос', value: 'Блонд'}, {label: 'Телосложение', value: 'Стройное'}, {label: 'Цвет глаз', value: 'Зеленый'}, {label: 'Доход', value: 'Средний'}, {label: 'Национальность', value: 'русская'}, {label: 'Языки', value: ['русская', 'английский']}]

insert values ​​into value from such an object
age:32
avatar:"thumb_20170718133451.jpg"
datas:Object
body:"Полное"
city:"Балларат"
country:"Австралия"
eye:"Зеленые"
hair:"Черные"
height:170
income:"Высокий"
langs:Array(1)
last_visit:Jan 1, 1970 1:00:00 AM"
nation:"Русский"
position:"Не замужем"
purposes: Array(1)

maybe lodash or something else will help me?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kulakov, 2017-08-23
@nickola105

Only handles, there is not enough data to link the object and the array.
Or add type id to the array like this: {id: "hair", label: 'Hair color', value: 'Blonde'} and further:

datas.forEach(item => { item.value = obj[item.id] })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question