How do I loop through chars in a string in javascript?
<p>I have the following js and receiving error at the <code>foreach</code> loop:</p>

<pre><code>function bitCount(n) {
var strBitCount = (n &gt;&gt;&gt; 0).toString(2);
var answer = 0;
var c = '';

foreach(c in strBitCount)
{
    if(Number(c) == 1)
    {
        answer++;
    }
}
  return answer;
}
</code></pre>