JavaScript program that returns the number of vowels found within a string
Posted by SceDev
Last Updated: February 24, 2024

Write a JavaScript program that returns the number of vowels found within a string.

Code:

function countVowelsInString(str) {
    const result = str.match(/[aeiou]/gi);
    return result ? result.length : 0;
  }
  
var result = countVowelsInString('helloworld')

console.log(result);
Related Content
Count vowels in a string using Java
Count vowels in a string using Java
Samath | Jan 17, 2024