var car = {
  name: "roll_royce",
  add: [
    { color: "red", location: "USA_1" },
    { color: "green", location: "USA_2" },
  ],
  pay: { type: { name: "USD" } },
};
I want to write a function like this:
getCar(car, 'add.0.location') // USA_1, same as car.add[0].location 
getCar(car, 'pay.type') // USD, same as car.pay.type
But I can't use car."string". how to solve it. thanks advance ...
 
     
    