Skip to content

Instantly share code, notes, and snippets.

@Mariana88
Created April 12, 2018 11:43
Show Gist options
  • Save Mariana88/30d7887720e7acf390fa2dd08587e9b7 to your computer and use it in GitHub Desktop.
Save Mariana88/30d7887720e7acf390fa2dd08587e9b7 to your computer and use it in GitHub Desktop.
Objects exercise - Is there a better way to determine if letter is a vowel than what I have done? (second for loop can be improved?)
function removeVowels (str){
let strNoVowels = "";
let strObject = {};
const vowels = {
v1: "a",
v2: "e",
v3: "i",
v4: "o",
v5: "u"
}
for (let i=0; i<str.length; i++){
strObject[i] = str[i];
}
for (let x in strObject){
if (strObject[x] == vowels.v1 || strObject[x] == vowels.v2 || strObject[x] == vowels.v3 || strObject[x] == vowels.v4 || strObject[x] == vowels.v5){
} else {
strNoVowels = strNoVowels + strObject[x];
}
}
return strNoVowels;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment