Search your name in text


#1


https://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/5?curriculum_id=506324b3a7dffd00020bf661


Your second 'for ; loop should stop when it reaches the current point in the string + myName.length


/*jshint multistr:true */
var text = " yolo ello hello pello samarth khello chlo samarth";
var myName = "samarth"
var hits = [];
for ( var i = 0;i < text.length;i+=1){
    if (text[i] === 's' ){
        for(var j = i;j<(i + length.myName);j+=1){
            hits.push(text[j]);
        }
    }
}


#2

this should be written as myName.length


#3

And just increment generally like,

j++ instead of by 1 like,


#4

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