Accessing Object Properties with Variables

I am a little bit confused about this lesson:
what is the use of accessing the object property like this:

const dogs = {
  Fido: "Mutt",
  Hunter: "Doberman",
  Snoopie: "Beagle"

const myDog = "Hunter";
const myBreed = dogs[myDog];

when you can do this much easier by console.log(dogs.Hunter):

You don’t always know which property you will need to access when writing a more general function.

This way you don’t need to make a separate function for every single thing you want to do to every single possible property.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.