I have 2 objects with format:
obj1 = [
{
"code": "in_today",
"text": "Today"
},
{
"code": "in_week",
"text": "This week"
},
{
"code": "in_month",
"text": "This month"
},
{
"code": "normal",
"text": "Other"
}
]
obj2 stores "code" value which defined in obj1:
obj2 = ["in_today", "in_week", "normal"]
How can I use obj2's values to change obj1 into something likes:
[
{
"code": "in_today",
"text": "Today",
"selected": true
},
{
"code": "in_week",
"text": "This week",
"selected": true
},
{
"code": "in_month",
"text": "This month",
"selected": false
},
{
"code": "normal",
"text": "Other"
"selected": true
}
]
What's the best solution for this case? Thanks!