How to get value from an object searched key is in string

I have an object

const lead = {
  companies: [{
    schoolName: "ABC",
    education: "Graduation"
  }, {
    schoolName: "DEF",
    education: "Graduation2"
  }],
  hello: 'world',
  education: {
    graduation: 'true',
  },
  nameArray: ['hello', 'world']
}

Variable I am getting from frontend

‘companies[0].schoolName’

I just have to send the value if it exists in the object