OneCompiler

count the total vowel and consonants

225

var name = 'This is a really simple sentence';
var len = name.length;
var vcount = 0 , i , cCount = 0;
var str=name.toUpperCase();
console.log("total length of the Strign is"+ len)
for( i =0 ;i < str.length ; i++)
{
if(str.charAt(i)=='A' || str.charAt(i) == 'E' || str.charAt(i) == 'I'
|| str.charAt(i) == 'O' || str.charAt(i) == 'U')
{
vcount++;
}
else if(str.charAt(i)>='A' && str.charAt(i)<= 'Z')
{
cCount++
}
}
//var conso=len-count;
console.log("total number of vowel is "+ vcount);
console.log("total number of consonants is "+ cCount);