5/7 I am begging you lot, someone please help me.I am lost


var text = "Hello my name is Dennis. I was called Denyo by my family. I love my name Denyo.";

var myName = "Denyo";

var hits = []

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



This is my code and i literally dont know why it is not working. Please help


You are so close to where you're supposed to be that it'll be frustrating when you figure it out, but I'll help you understand what's going on real quick so you can fix the mistake! :smiley:

for (var j = i; j < (j + myName); i++) {

Right now you're incrementing " i " in two for loops. Right now the second for loop is incrementing so far that it will crash your browser (An infinite loop)

As a rule of thumb whenever you're incrementing something in the for loop, stick to the variable that was also initialized in the for loop, " j ". This will make sure that you don't have any infinite loops in your code.

The second issue is the condition ; j < (j + myName) ;. Right now this condition will never be true, because you will never be able to have " j " be greater than itself plus the variable "myName"

So literally if you just switch the j in the condition with the " i++" you will fix your code.

I hope this helps!

for ( var j = i ; j < ( i + myName) ; j++) {
    //Code here!