6/7 I can't figure out what I'm doing wrong


#1

var text="bla bla Ruxandra bla bla Ruxandra";
var myName="Ruxandra";
var hits = [];

for (var i=0; i<(text.length); i++) {
if (text[i] === 'R') {
for (var j=i; j<(i+myName.length); j++) {
hits.push(text[j]);
}
}
}

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

I don't understand why it only returnes []. ?? Please help me. Thank you!


#2

Remember, '=' is not a comparator in coding. '===' means equal to, remember?


#3

Oh, that makes sense now. Thank you very much!