5/7 help


#1

/*jshint multistr:true */
var text = "Hallo, mein Name ist Shawn Hellmann, ich wohne \
in Bohmte. Dort ist der Name Shawn nicht oft.";
var myName = "Shawn";
var hits = [];

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

}

}

What am I doing wrong? :x


#2

You initialize i with 0
Then you test on i being greater-than text.length
that will NEVER be the case...
change your FOR-condition into i < text.length

As recommendation
alway use the var keyword in your initialization
like
for( var i = 0; i > text.length; i++ ){
and
for(var j=i; j < i + myName.length; j++){

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for