Simple JavaScript Word Count Function
<p>I finally started to learn JavaScript and for some reason I can't get this simple function to work. Please tell me what I am doing wrong.</p>

<pre><code>function countWords(str) {
/*Complete the function body below to count
  the number of words in str. Assume str has at
  least one word, e.g. it is not empty. Do so by
  counting the number of spaces and adding 1
  to the result*/

var count = 0;
for (int 0 = 1; i &lt;= str.length; i++) {
   if (str.charAt(i) == " ") {
        count ++;
    }
}
return count + 1;
}
console.log(countWords("I am a short sentence"));
</code></pre>

<p>I am getting an error <code>SyntaxError: missing ; after for-loop initializer</code></p>

<p>Thanks for your assistance</p>
