Why does hits have to equal 0 in this line of code?


#1

Hello, I am on lesson 6 , exercise 6 Log it, I finished the exercise correctly however i am confused why the hits.length has to equal 0 in the if else statement. If someone could explain that to me that would be awesome Thanks!

/*jshint multistr:true */
var text =" Hello my name is Clayton how are you doing today?";


var myName ="Clayton"


var hits = []


for(var i = 0; i < text.length; i++) { if(text[i] === myName[0]) { for (var l = i; l < i + myName.length; l++) hits.push(text[l]); {
        }
    }   
}
if(hits.length === 0) { console.log("Your name wasnt found!") 
} else { console.log(hits);
}

#2

if the length of hits is zero, your name is not found/present in text so you inform the user the name is not found

what do you not understand about it?


#3

Makes sense was having a blonde moment lol. i did it yesterday tested it and it worked and was confused why i even did it lol


#4