This doesnt work :(


#1


/*jshint multistr:true */
var text = "Hey, how are you \ doing? My name is Prashant. Hi I am Prashant. Prashant ";
var myName = "Prashant";
var hits = [];

for( var i = 0; i<= text.length; i++){
    if (text[i] ==='P'){
        for( var j = i; j<=myName.length; j++){
            hits.push(j);
        }
    }
}
console.log(hits);


#2

HI this line

hits.push(j);

you should push text[j] instead of j


#4

thank you so much :slight_smile:


#5

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