Skip to content

Instantly share code, notes, and snippets.

@angvishvish
Created February 20, 2015 19:07
Show Gist options
  • Save angvishvish/77e33439846e9cc93814 to your computer and use it in GitHub Desktop.
Save angvishvish/77e33439846e9cc93814 to your computer and use it in GitHub Desktop.
Count the number of vowel in javascript
function VowelCount(str) {
var count = str.split('').map(function (item) {
return item.match(/[aeiouAEIOU]/) ? item : '';
}).join('');
return count.length;
}
// keep this function call here
// to see how to enter arguments in JavaScript scroll down
VowelCount(str);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment