title: Capitalizing first letter of each word in a string using Javascript
body: <p>I need to Capitalizing first letter of each word in a string using Javascript but ignore if the word is article/preposition.</p>
  
  <pre><code>var string = "at the drop of a hat";
  </code></pre>
  
  <p>should return</p>
  
  <pre><code>"At the Drop of a Hat"
  </code></pre>
  
  <p>Please see here that -
  1. Every 1st letter of each word is in uppercase
  2. 'the' and 'a' being articles were not capitalized
  3. 'of' being a preposition was not capitalized
  4. 'at' was capitalized even though it is a preposition as it is start of a sentence.</p>
  
  <p>I could do #1 by </p>
  
  <pre><code>string.toLowerCase().replace(/(^[a-z])|(\s[a-z])|([-,:!?\&lt;"&gt;';+‘@`€$*&amp;.\\/][a-z])|(\s[а-яё])|(^[а-яё])/g,function(f){return f.toLocaleUpperCase();});
  </code></pre>
  
  <p>But, this return "At the Drop Of A Hat".</p>
  
  <p>How can I ignore capitalizing articles and prepositions if they're not occurring as first word in a given sentence (i.e. #2,#3 and #4 above)?</p>