View Single Post
Old 11-12-2012, 10:34 PM   PM User | #12
triko
New Coder

 
Join Date: Oct 2012
Location: Italy
Posts: 72
Thanks: 3
Thanked 0 Times in 0 Posts
triko is an unknown quantity at this point
Quote:
Originally Posted by Logic Ali View Post
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
triko is offline   Reply With Quote