Hi everyone!
I just finished Whale Talk. My code is listed below. This works perfectly fine (though, please, if there is a way I can improve it let me know!) Initially, though, I had resultArray.push(i), which was returning numbers interpolated in the strings. When I changed it to resultArray.push(input[i]), it stopped doing that. I can’t figure out why it would push numbers to begin with, though. Any insight?
Thanks again!
`let input = ‘Hi, Human’;
const vowels = [‘a’,‘e’,‘i’,‘o’,‘u’];
const resultArray = ;
for (let i = 0; i <= input.length; i++) {
for (let j = 0; j < vowels.length; j++) {
if (input[i] === vowels[j]) {
resultArray.push(input[i]);
}
} if (input[i] === ‘e’) {
resultArray.push(input[i]);
} if (input[i] === ‘u’) {
resultArray.push(input[i]);
}
}
console.log(resultArray.join(’’));`
Cheers!
—Codecademy Community Managers