Counting Vowels in JavaScript with Efficient Looping

💡 Day 2 of My Web Development Journey — JavaScript Practice 📌 Today’s Practice: Counting Vowels in a String const str = "javascript"; const vowels = "aeiouAEIOU"; let count = 0; for (let letter of str) { if (vowels.includes(letter)) { count++; } } console.log(count); 🔍 What I learned: How to loop through a string efficiently How .includes() simplifies conditions Writing cleaner, more readable code 🚀 Not perfect—but better than yesterday. If you're learning too, don’t wait to feel ready. Just start. #JavaScript #WebDevelopment #100DaysOfCode #LearningInPublic #FrontendDeveloper

good but use conditional to convert letters into lower case before checking.if (vowels.includes(letter.toLowerCase())).

To view or add a comment, sign in

Explore content categories