javascript counting vowels, consonants and show the occurrance
<p>I'm having trouble to figure out how to count vowels, consonants and declare how often the vowels appears separately, from user input.
The user put any text ex: “Mischief managed!” and result must be:
a: 2
e: 2
i: 2
o: 0
u: 0
non-vowels: 11</p>

<pre><code>var userData = prompt ("Enter any text here");
var a = 0;
var e = 0;
var i = 0;
var o = 0;
var u = 0;
var consonants = 0;
var count;

for (count = 0; count &lt;= userData.legth; count++){
   if((userData.charAt(count).match(/[aeiou]/))){       
     a++;
     e++;
     i++;
     o++;
     u++;
    }else if((userData.charAt(count).match(/[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]/))){

    consonants++;
}
}
 console.log ("a: " + a);
 console.log ("e: " + e);
 console.log ("i: " + i);
 console.log ("o: " + o);
 console.log ("u: " + u);
 console.log ("consonants: " + consonants);
</code></pre>

<p>But it's not working. I already searched in many other forums but, I didn't find anything like this.</p>