Pass object and specify attribute to function for processing in javascript

So I want to define a function in javascript that takes an object emp:

    var emp = {
        firstName: "john",
        lastName: "smith"
    };
    capitalize(emp, "firstName");
    //emp.firstName is John

    capitalize(emp, "firstName");
    //emp.lastName is Smith

I specify which attribute to process

    funciton capitalize(employee, attribute)
    {
        // code to capitalize the sepecified attribute only
        return object;
    }

My current way of solving this is to specify a function for each attribute. But if it’s possible to specify an attribute for the function it would be shorter code and more dynamic.

I have searched for this concept, but I probably failed at specifying a good keywords for this problem.