Dynamically create variable name from a loop

Let’s say I have a list of hats as children in a UI panel,
Each hat has a correct name of what it is, such as Tophat, Cowboy, Fedora, etc.

Whether or not their unlocked is stored in bools named boughtHatTophat, etc

How can I make a simple loop to check each variable without individually checking each one?

I would like it to run something like this, in how you can combine strings together with +

foreach (Transform child in hatList)
        {
            if (boughtHat + child.name == true)
            {
                child.gameObject.SetActive(true);
            }
            else
            {
                child.gameObject.SetActive(false);
            }
        }

You can’t. What you can do instead is store the booleans as an array, then match the indices with the hat array.