Whale talk js prokect

let input = 'Hi my name is jeff'; let vowels = ["a", "e", "i", "o", "u"]; let resultArray = []; for (let inputIndex = 0; inputIndex < input.length; inputIndex++) { if (input[inputIndex].toLowerCase() === 'e') { resultArray.push(input[inputIndex]); } if (input[inputIndex].toLowerCase() === 'u') { resultArray.push(input[inputIndex]); } for (let vowelIndex = 0; vowelIndex < vowels.length; vowelIndex++) { if (input[inputIndex].toLowerCase() === vowels[vowelIndex]) { console.log(input[inputIndex]); resultArray.push(input[inputIndex]); } } } console.log(resultArray);

Hi All I have an issue.
Im trying to get ‘u’ to be pushed into my resultArray but for some reason its not coming up. Please let me know what I can do

Hi there!

After changing the input to the example phrase, “turpentine and turtles,” it gives the expected result.

Your code does push u to resultArray.

As an aside, we notice you are using a reserved word as a variable name in line 1.

let input = 

We would caution you against using any reserved words (built-in function and method names, built in global constants, and the likes). Just as we would not write,

list = []

we would not write,

input =

Both of those are built in functions.

lst = []
user = input()

Hopefully this has a meaningful impact on how you choose your variable names and you avoid running into problems in the future.

1 Like

Having come back to my senses, there are no list objects in JS; nor is there an input() function. One’s mind was completely on another language.

let input = prompt("Are tomatoes a vegetable or a fruit?", "don't know")

The variable name is perfectly valid in JS and does not conflict. It can even be used to store the value attribute of an <input> element.

Kind 'o blushing, just now.

I see
thank you all for replying it means a lot!