Skip to content

Instantly share code, notes, and snippets.

@brianmarete
Last active February 21, 2017 13:11
Show Gist options
  • Save brianmarete/47f7ff2fa0699779e0496afea0e20348 to your computer and use it in GitHub Desktop.
Save brianmarete/47f7ff2fa0699779e0496afea0e20348 to your computer and use it in GitHub Desktop.
A JavaScript function to receive a sentence and return a copy of the sentence without vowels.
function removeVowels(sentence) {
var vowels = ['a', 'e', 'i', 'o', 'u'];
var newSentence = [];
for (var i = 0; i < sentence.length; i++) {
if (vowels.includes(sentence[i])) {
newSentence.push('-');
} else {
newSentence.push(sentence[i]);
}
}
return newSentence.join("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment