Quote:
Originally Posted by Logic Ali
Slightly simpler but easily avoided for a beginner. I suspect the original intention may have been to build a string from the extracted vowels, otherwise counting the consonants would be unnecessary.
Code:
<!DOCTYPE html >
<html>
<head>
<title>TEST</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function calculateName( str )
{
var vowelString = "", ch;
for( var i = 0; (ch = str.charAt( i )); i++ )
if( "aeiouAEIOU".indexOf( ch ) > -1 )
vowelString += ch;
document.getElementById('here').innerHTML = vowelString;
return str.length - vowelString.length;
}
</script>
</head>
<body>
<button onclick="alert('Consonants: '+calculateName('BillyJoeBoo'))" >PUSH</button>
<div id="here"></div>
</body>
</html>
|
Logic, i'm a low level in Javascript and what that you write it's more complicately for me

And don't understand more passages of problem