Still not working!


#1

/*jshint multistr:true */
var text = "Hello there";
var myName = "Esther";
var hits = [];

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

}

}

if (hits.length === 0) 
{
    console.log("Your name wasn't found!");
} 
else 
{
    console.log(hits);
}

#2

You will need to have the value of myName (i.e Esther) somewhere in the variable text for this program to work. That's actually the whole point of the program


#3

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