Last active
June 28, 2023 18:45
-
-
Save thiegomoura/d760e4cd5b7e6d33d890df1091087751 to your computer and use it in GitHub Desktop.
Vowel count with async function
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 vowels = ["a", "e", "i", "o", "u"] | |
function vowelCount(text, callback) { | |
const letters = text.split('') | |
const vowelCount = letters.reduce((acc, value) => { | |
const isVowel = vowels.includes(value.toLowerCase()) | |
if (isVowel) acc++ | |
return acc | |
}, 0) | |
return callback(vowelCount) | |
} | |
function print(value) { | |
console.log('result: ', value) | |
} | |
vowelCount('thiego', print) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment