Hi, I am working through loops in JavaScript right now with the project Whale Talk. My code works but there is one part don’t understand why it behaves the way that it does. Here is my code:
https://www.codecademy.com/workspaces/63d2e321206871a64dd1ed93
The code I’m a bit confused about is from step 7 in the project:
console.log(`vowelIndex is ${vowelIndex}`)
if (input[inputIndex] === vowels[vowelIndex]) {
//console.log(input[inputIndex])
resultArray.push(input[inputIndex]);
}
}
}
When printing the vowelIndex to the console (I will comment this out later), numbers 0-4 are printed repeatedly. I know it says in step 7 that this will happen, but I don’t understand why it prints so many times. Why doesn’t it go though the numbers just once?
Also, please give me any other feedback on the code if you want to!