Console won't log my name


I have looked the code up and down but can't find where I went wrong. The console just logs "[]" and I'm not getting an error message.

/*jshint multistr:true */
var text = "Lorem ipsum dolor Alessandro sit amet, consectetur adipiscing Alessandro elit.";
var myName = "Alessandro";
var hits = [];
for(var i = 0; i < text.length; i++){
if (text[i] === "A"){
for(var j = i; j < myName.length + i; j++){
if(hits.length = 0) {
    console.log("Your name wasn't found!");
} else {


try not to use var j=i, instead only j=i

add a semi colon after

hope it will fix your problem


Did both of those things, it didn't work :,(


i have same problem.

I completed the exercise, but doesn't log my name... :frowning:

var text = "Hey, how are you doing? My name is John. I am trying to learn how to code, \but this is not going very well. As usual Mr. John Braz starts loosing interest once he finds something else to do.";

var myName = "John";

var hits = [0];

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


First of all, why are you trying to set hits.length as 0? It should be like

hits.length === 0

Also, I'm pretty sure the lesson states "Your name wasn't found!" instead of nameS.
I hope this helps.


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