Count Vowels in String with JavaScript

💻 JavaScript Beginner Level Practice – Count Vowels function countVowels(str){ let vowels = "aeiou"; let count = 0; for(let char of str.toLowerCase()){ if(vowels.includes(char)){ count++; } } return count; } console.log(countVowels("hello world")); 📌 Output: 3 💡 Explanation: This program loops through each character in a string and checks whether it is a vowel (a, e, i, o, u). If it is a vowel, the count increases. #JavaScript #BeginnerLevel #CodingPractice #WebDevelopment

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories