Created
June 11, 2024 04:51
-
-
Save hassanuos/adf44bc01eeab28a2657a52b03712e23 to your computer and use it in GitHub Desktop.
count vowels in the string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const str = "Hey JS! You R AMAZING"; | |
const vowels = ["a", "e", "i", "o", "u"]; | |
function countVowels(data){ | |
let count = 0; | |
data.toLowerCase().split("").forEach((ch) => { vowels.includes(ch) && count++;}) | |
return count; | |
} | |
const numberOfVowels = countVowels(str); | |
console.log(numberOfVowels); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment