How to change a value of a nested property in an object dynamically [duplicate]

const array_of_property_names = ["A", "B", "C", "D"];

const nested_obj = {
  A: {
    B: {
      C: {
        D: 1
      }
    }
  }
}

In the event that array_of_property_names is dynamic, how can we use it to modify nested_obj?