I’ve been stuck on this same step for a while now and I can’t figure out what I’m doing wrong …
I’m trying to take the following code:
const input = ‘turpentine and turtles’;
const vowels = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’];
let resultsArray = ;
for (let i = 0; i < input.length; i++){
{
for (let j = 0; j < vowels.length; j++){
if (input[i] === vowels[j]){
console.log(vowels[j])
}
}
}
}
And this does what the question asks and compares the input
letter to every letter in the vowels
array resulting in: u
e
i
e
a
u
e
My issue arises when I try to “push” this to the resultsArray … The following code:
const input = ‘turpentine and turtles’;
const vowels = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’];
let resultsArray = ;
for (let i = 0; i < input.length; i++){
{
for (let j = 0; j < vowels.length; j++){
if (input[i] === vowels[j]){
resultsArray.push(vowels[j])
console.log(resultsArray)
}
}
Yields this:
Output-only Terminal
Output:
[ ‘u’ ]
[ ‘u’, ‘e’ ]
[ ‘u’, ‘e’, ‘i’ ]
[ ‘u’, ‘e’, ‘i’, ‘e’ ]
[ ‘u’, ‘e’, ‘i’, ‘e’, ‘a’ ]
[ ‘u’, ‘e’, ‘i’, ‘e’, ‘a’, ‘u’ ]
[
‘u’, ‘e’, ‘i’,
‘e’, ‘a’, ‘u’,
‘e’
]
What am I doing wrong? I’m so confused.