Check with the help of a loop if the string contains "y"

I am a beginner at JavaScript and I have to do an exercise with the instruction “using a loop, check if a string contains the letter “y”. Display “yes” if there is
one and “no” in the opposite case.” Can someone explain and help me, it’s for a training.

What have you tried so far? There are a few ways to tackle this.

let str = "I don't know why";  
let result = "non";

I tried with this :

for (let i = 0; i < str; i++){

You probably need to put something inside of that loop. What might be something that you want to do for every letter in the string?

what does this mean?

1 Like

i is less than str. I admit that I don’t know what to put in the loop, I’m a little lost.

What is str? how can a number be less than str?
Can you give an example of a value of i for which i < str is true and one for which it is false?