4. Your "if" statement 4/7


I don't know what is the problem my code below. please some help for this.

var text = "Hello world";
var myName = "Shinae";
var hits = [];

for ( var i = 0; i < text.length; i++ ){ 
    if(myName[i] === "S"){} 


Hello :slight_smile:

Your for loop iterates through characters of text, so i is some position in the text. That is why current letter in instructions means text[i], not myName[i].

Extra note, variable text should contain myName value. So you can change it, for example, to:

var text = "Hello Shinae"

this will be important in the next exercises.


Thank you so much ! It worked !!


You're very welcome :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.