Why is it not working?


 the error says:ReferenceError: Can't find variable: hits

var text = "hey how are you \
doing? my name is William.";
var myName = "William";

for(var i = 0; i < text.length; i++){
if (text[i] === "W") {
for(var j = i; j < i + myName.length; j++){
if (hits.length === 0) {
	console.log("Your name wasn't found!");
} else {


Take a careful look at the error message. It's saying that some variable doesn't exist.
Should it exist? Where and when should it have been created?


take a closer look on the declared variables. the error says, the variable "hits" was not declared.


i'm not sure where it should be. actually it doesn't matter i've found it thanks so much for the help :smile: :slight_smile:


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