Adding string data to an expression for evaluation

Hi, I have the following function:

getInfo = function (input, arrayData, desiredResult)
{
    for (i = 0; i < arrayData.length; i++)
    {
        if (arrayData*.button == input)
        {
            return arrayData*.desiredResult;
        }
    }
};

arrayData is a multidimensional array containing objects.

What I need returned is arrayData*.desiredResult, where desiredResult is a string passed to the function. For example:

test(“dogs”, theArray, “color”) needs to return the evaluated value of arrayData*.color. How can I achieve this? Thanks!