I would personally use test()
to test my strings: MDN test()
This will simply test a string to see if it matches a regex pattern.
Another tool which will really help you is RegexPal: Regex Pal
This will make it a lot easier for you to see what you regexes are doing without having to run the code.
Your vowel regex should only include vowels as mentioned by @ieahleen. So your vowel regex should be /[aeiou]/
In order to find the position of a vowel it might useful for you to use a for
loop. This will allow you to test each character of a string against your regex, systematically: MDN For Of Loop
The example I have included below demonstrates how a for of loop can iterate over a string and return the index of the first vowel:
const regex=/[aeiou]/;
for(let char of str){
if(regex.test(char)){
return str.indexOf(char);
}
}
As you can see, I have removed the i identifier as the task states all words will be lowercase anyway. What the above loop is saying is as follows:
For every character char in the string str test is against regex and, if it matches return the index.
Hope this sets you on your way