Prints empty array


#1

Prints empty array,
Hi folks, please help code looks fine, doesn't give me any errors msg however prints an empty array on the console, where am I going wrong?

text = "I am trying very hard to learn proramming, Milen\
and tomorrow i have got an interview at Milen college \
for becoming a IT student called Milen";

var myName = "Milen";
var hits = [];

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


#2

this line:

if (hits.length = 0)

you set the length of your hits array to 0 (single equal signs means assign), use two or three equal signs to compare


#3

Thanks for your help, it works


#4