简体   繁体   中英

converting data structure in JS

I got this problem, I don't know why I'm struggling to resolve it. So I'm using ES6 with react and I appreciate all the help to turn this

[ { a: [{}, ....], b: {} }, {...}, ... ]

to this

[ { a: [{}, ....], b: [{}] }, {...}, ... ]

Do you need rewrite with a array assigned

Acess index in array and current "b" object look this example bellow

 let problem = [ { a: [{}, {}], b: {} }, {}] problem[0].b = [ problem[0].b ] console.log(problem)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM