I have two arrays:
a1= ['All', 'one', 'two'];
a2= ['Users', 'Service', 'Admin'];
I need to return an array of object like this
[
{value: 'All', label: 'Users'},
{value: 'one', label: 'Service'},
{value: 'two', label: 'Admin'}
]
Can somebody help?
Try this:
const a1 = ['All', 'one', 'two'];
const a2 = ['Users', 'Service', 'Admin'];
a1.map((item, index) => ({
value: item,
label: a2[index]
}))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.