Hello there,
Need your help to review my understanding of the concept.
Why did we get 6 times “U” & 6 times “E” in here:
let input = 'turpentine and turtles'
const vowels = ['a','i','u','e','o']
let 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' || input[i] === 'u'){
resultArray.push(input[i])
}
}
}
console.log(resultArray.join('').toUpperCase())
while we get 2 times “U” & 2 times “E” (as the project expected) in here:
let input = 'turpentine and turtles'
const vowels = ['a','i','u','e','o']
let 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' || input[i] === 'u'){
resultArray.push(input[i])
}
}
}
}
console.log(resultArray.join('').toUpperCase())
Appreciate for the help.