title: Assigning values inside a foreach loop
body: <p>Imagine an array of contacts sorted on name.
  This array can be outputted like:</p>
  
  <pre><code>&lt;ul data-bind="foreach: contacts&gt;
      &lt;li data-bind="text: name"&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>What I would like to do is specify a heading for each li which has a different starting letter, so e.g. displaying A, B, D...</p>
  
  <pre><code>- A
  - Anderson
  - Andrews
  - B
  - Bellamy
  - D
  - Davidson
  - Davis
  </code></pre>
  
  <p>In normal programming language I would define a variable containing the first letter of the name and check inside the foreach loop to see if it's different. And if this is the case, displaying a header.</p>
  
  <p>How should I do this with knockout.js?</p>