title: Not Understanding How to Capitalizing Text in Angular
body: <p>My friend helped me write a custom filter in AngularJS to help me capitalize one of the values in my object for one of my arrays. But didn't have time to explain to me what he did. Was just wondering if anyone can be kind to help me understand this block of code:</p>
  
  <pre><code>.filter('capitalizetext', function() {
     return function(name) {
  name = ( name === undefined || name === null ) ? '' : name;
  return name.toString().toLowerCase().replace( /\b([a-z])/g, function(change) {
    return change.toUpperCase();
    });
   };
  })
  </code></pre>
  
  <p>1st part that I don't understand is:</p>
  
  <pre><code>name = ( name === undefined || name === null ) ? '' : name;
  </code></pre>
  
  <p>Why did he do this?</p>
  
  <p>2nd part I don't understand is:</p>
  
  <pre><code>return name.toString().toLowerCase().replace( /\b([a-z])/g,
  </code></pre>
  
  <p>I understand that he is changing the string to all lowercase so that he can eventually convert it to capitalize the string but what is this: <code>( /\b([a-z])/g</code></p>
  
  <p>Not really following what he did there.</p>
  
  <p>Please help!</p>