Search text for your name 6/7


#1

Hi All,
an someone please assist me as I am getting an error saying "Did you remember to log the results of the search to the console".

Below is my code and I cannot figure out what is wrong

var text = "Hello, How are you? / My name is Daniel! / My name is Daniel";
var myName = "Daniel";
var hits = [];
for (var i = 0; i < text.length; i++)
{
if (text[i] == 'D')
{
for (var d = i; d < (i + myName.length); d++)
{
hits.push(text[d]);
}
}
}

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


#2

I'm not sure if this is the problem but your missing an "=" in "if (text[i] =='D')".


#3

Unfortunatly this has not fixed the issue