Javascript String count vowel

Description

Javascript String count vowel

function VowelCount(str) {
    // Split into characters.
    var letters = str.split('');

    // Map-Reduce
    var isVowel = function(x) {
        return Boolean(x.match(/[aeiou]/i));
    }/*from  w w w.  ja va 2  s  .  c  om*/

    return letters.map(isVowel).reduce(function(x, y) { return x + y; });
}


console.log(VowelCount("are you a dreamer?"));



PreviousNext

Related