Skip to content

Instantly share code, notes, and snippets.

@alexcrist
Created March 4, 2021 16:22
Show Gist options
  • Save alexcrist/51c62db3211c89590d13d2758cf1c644 to your computer and use it in GitHub Desktop.
Save alexcrist/51c62db3211c89590d13d2758cf1c644 to your computer and use it in GitHub Desktop.
function disemvowel(str) {
let noVowelStr = '';
for (const letter of str) {
// Determine whether each letter is a vowel
const lowerCaseLetter = letter.toLowerCase();
const isVowel = (
lowerCaseLetter === 'e' ||
lowerCaseLetter === 'i' ||
lowerCaseLetter === 'o' ||
lowerCaseLetter === 'u' ||
lowerCaseLetter === 'a'
);
// If not a vowel, add the letter to the output string
if (!isVowel) {
noVowelStr += letter;
}
}
return noVowelStr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment