Hello,
- When console.log(resultArray) the output is as show below, rather than just a one line array, Why is this?
“[
‘u’, ‘u’, ‘e’, ‘e’,
‘i’, ‘e’, ‘e’, ‘a’,
‘u’, ‘u’, ‘e’, ‘e’
]”
- Also, I cant quite understand why this code automatically know to push an additional letters e and u? Isn’t the " input[i] === ‘e’ || input[i] === ‘u’" a condition that has to be met? Why don’t I have to state what needs to be pushed in the method.push()?
" if (input[i] === ‘e’ || input[i] === ‘u’){
resultArray.push(input[i]);"
https://www.codecademy.com/courses/introduction-to-javascript/projects/whale-talk
let input = ‘turpentine and turtles’;
const vowels = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’];
let resultArray = ;
for (let i = 0; i < input.length; i++) {
console.log(i)
if (input[i] === ‘e’ || input[i] === ‘u’){
resultArray.push(input[i]);
}
for (let j = 0; j < vowels.length; j++) {
console.log(j)
if (input[i] === vowels[j]) {
console.log(input[i])
resultArray.push(input[i])
}
}
}
let resultString = resultArray.join().toUpperCase()
console.log(resultString)
console.log(resultArray)