We want to know the index of the vowels in a given word, for example, there are two vowels in the word super (the second and fourth letters).
So given a string "super", we should return a list of [2, 4].
Some examples:Solution
function vowelIndices(word){
// 1. Define an empty array we can push index values into
var arr = [];
//2. Iterate through 'word', searching for vowels
for (i = 0 ; i ''<'word.length; i++) {
//3. Use 'indexOf' to find locations of vowels inside of 'word'
if ('aeiouy'.indexOf(word[i]) !== -1)
//4. As long as the vowels are located inside of 'word' (ie not -1), push their index location into an array
arr.push(i+1);
}
//5. Print the array
return arr;
}