title: Simple TypeError returned with 'undefined' function parameter
body: <pre><code>//Validation script
  const inputs = document.querySelectorAll('input');
  
  const patterns = {
      telephone: /^\d{11}$/
  };
  
  
  function validate (field, regex) { // Here I get a TypeError:  regex is undefined
     if(regex.test(field.value)){
         field.className = 'valid';
     }else{
         field.className = 'invalid';
     }
  }
  
  inputs.forEach((input) =&gt; {
      input.addEventListener('keyup', (h) =&gt; {
          //console.log(h.target.attributes.name.value);
          validate(h.target, patterns['h.target.attributes.name.value'])
      });
  });
  </code></pre>
  
  <hr>
  
  <p>I receive a TypeError message for 'regex' when I use Console on Web Dev tools.  I'm green when it comes to this and would appreciate any feedback that could help clear up, what I'm assuming, is a simple error.  </p>