Created
April 12, 2018 11:43
-
-
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?)
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
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