Contact: aviboots(AT)netvision.net.il
39,939 questions
51,876 answers
573 users
function vowel_count(str) { const vowels = 'aeiouAEIOU'; let count = 0; for (let i = 0; i < str.length ; i++) { if (vowels.indexOf(str[i]) !== -1) { count += 1; } } return count; } console.log(vowel_count("javascript programming")); /* run: 6 */
function vowel_count(str) { const vowels = /[aeiou]/gi; const result = str.match(vowels); const count = result.length; return count; } console.log(vowel_count("javascript programming")); /* run: 6 */