I want to remove the consonants in a string until I get to a vowel. For example the string "glove"
, the results should be "ove"
.
This was my attempt but it will only remove the first consonant.
var newStr = str.split("").splice(1, ).join("");
var removeLetter = str.split("").shift();
2
Answers
Well, in order to do something until you need a loop. First, break your input string
"glove"
into a char array using.split('')
, then check for each char whether it matches any of your defined vowels (['a', 'e', 'i', 'o', 'u']
). When the first vowel has been found you break the process, put your chars back together using.join()
and return your result.You can use a function to delete all words until your condition.
But if you do not want that way, this is other way you can do it.