Question 5!( Search for your name in text)


#1

Please I don't know why it does not work.
2. I also do not understand any part from the second loop

var text = ("Perez! I have not seen you in a long time, how are you doing, I went to a perez friday and i heard that perez was the dj! I am proud of you perez");
var myName = ("perez");
var hits = [];
for (var i=0;iif(text[i] === "P"){
for (var p = i;p hits.push(text[p]);
}
console.log(hits)


#2

When writing strings, the quotes are all that is necessary. We do not normally wrap strings in parentheses.

/*jshint multistr:true */
var text = "Perez! I have not seen you in a long time, how are you \
doing, I went to a Perez Friday and i heard that Perez was the dj! \
I am proud of you Perez";
var myName = "Perez";

The escapes permit linebreaks. The jshint comment is required for this to work.

The above is incorrect, and is actually overlapping two statements. The same applies to the inner loop.

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

#3

Thanks Alot it worked, I don't understand from this part
for (var p = i;p hits.push(text[p]);
}
}
console.log(hits)