Can anyone show me the complete code?


hello I would be very glad if you can help me get through this, Im stuck in making my code run probably :frowning:
my code for "search for your name" challenge as follow currently on step 5

var text = "Hello my friends names are as follow: Rayan Ali Othman Nasir somaida Jordan Sara " ;
var myName= "Othman";
var hits = [];

for (var a=0; a>text.length; a++) {
    if (text[i]=== myName[0]) {
    for (var b = a; b <(i + myName.length); b++){

the error:
"It looks like your second 'for' loop isn't pushing values to the hits array. Make sure it's working properly and that myName's text appears somewhere in the text variable."

thanks in advance :slight_smile:


if you decide to use a instead of i like the exercise suggest, you should use a everywhere instead of i.

Uhm.. this loop:

for (var a=0; a>text.length; a++)

a starts at zero, a > text.length is then already false from the beginning, use < instead of >, so it can increase until it finishes the loop


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