title: How can a function accept an undeclared variable as a parameter?
body: <p>I am working on a pre-boot camp problem set.  The following problem asks that we code a reply based on the number of times a customer has visited the restaurant.  An object contains the customer names and number of visits.  The function has 'customerName' parameter passed to it, yet customerName has not been declared.  I am confused as to why the object 'customerData' was not passed to the function, instead the actual keys 'names of the customers' are passed.  Code follows:</p>
  
  <pre><code>/*Write a function called "greetCustomer".
  *
  *Given a name, "greetCustomer" returns a greeting based on how many times that
  *customer has visited the restaurant.  Please refer to the customerData object. 
  */
  
  var customerData = {
    'Joe': {visits: 1 },
    'Carol': {visits: 2 },
    'Howard': {visits: 3, },
    'Carrie': {visits: 4 }
  };
  
  var greetCustomer = function(customerName) {
    for (var customer in customerData) {
      if (customer === customerName) {
          return 'Hello '+ customer + ', welcome back for visit #' + (customerData[customer].visits + 1) + '!';
      }
    }
    return undefined;
  };
  
  greetCustomer('Carrie');
  </code></pre>