Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Push parent arrays element and chidren array into new array in javascript

$
0
0
"items": {"hotdrinks": [  {"id": "9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f","price": 20,"name": "Tea","img": "../assets/img/HotDrinks/1_udupibhavan.jpg"  },  {"id": "9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f","price": 25,"name": "Coffee","img": "../assets/img/Hot Drinks/2_udupibhavan.jpg"  },  {"id": "9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f","price": 50,"name": "Hot Milk","img": "../assets/img/Hot Drinks/3_udupibhavan.jpg"  },  {"id": "9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f","price": 70,"name": "Horlicks","img": "../assets/img/Hot Drinks/4_udupibhavan.jpg"  },  {"id": "9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f","price": 80,"name": "Badam Milk","img": "../assets/img/Hot Drinks/5_udupibhavan.jpg"  }],

}

json i want to achieve using javascript. im just new to handling arrays and objects. thanksfound the answer given by Jeeva which works perfectlyfuture answers are welcome since we can know diffferent methods to achieve the same json object

 dataArray = [ {title:"Hotdrinks", content: [{"id": "9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f","price": 20,"name": "Tea","img": "../assets/img/HotDrinks/1_udupibhavan.jpg"      },      {"id": "9aa113b4-1e4e-4cde-bf9d-8358fc78ea4f","price": 80,"name": "Badam Milk","img": "../assets/img/Hot Drinks/5_udupibhavan.jpg"      }]}

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>