0

how to merge array of this in react or javascript..can anyone help me with this i want the output something like..all the test array should be in one array...coz i need to find the minimum price and plus i need to show the mapping in ascending order

array :[
    {
    id:0,
    name:'something',
    test: [
          {
           id: 0,
           test_name:'blood',
           price:'200',
           },
            {
            id:1,
           test_name:'kidney',
           price:'300',
           }
         ]
       },
   {      
    id:1,
    name:'something1',
    test: [
          {
           id: 0,
           test_name:'blood2',
           price:'100',
           },
            {
            id:1,
           test_name:'kidney2',
           price:'100',
           }
         ]
       }

     ]

1 Answers1

1

You can use spread operator to merge two array.

var a = [{fname : 'foo'}]
var b = [{lname : 'bar'}]
var c = [...a, ...b] // output is [{fname : 'foo'},{lname : 'bar'}]
fixedDrill
  • 183
  • 1
  • 13