4. Your "if" statement 4/7


#1

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"){} 
    }


#2

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.


#3

Thank you so much ! It worked !!


#4

You're very welcome :slight_smile:


#5

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