Search Text For Your Name: Help me!


I'm trying to get the output/consolelog of "hillary" to display in the consolelog as the lesson wants it to. However I'm having trouble and can't find the 'bug'/what I'm doing wrong. Any help and explanation would be very much appreciated!

/*jshint multistr:true */
var text = "What is up kiddos? Haha my name's hillary wanna? HAHA  got those that put you to  Again I'm hillary fellow youngsters?";

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

for (var i = 0; i < text.length; i++)
    if (text[i] === "h");
for (var j = i; j < (myName.length + i); j++) {

    if (j === 0) {
        console.log("MY FACE!")
    } else {


You have multiple problems in the structure of your nested loops. They are:

  1. The second for loop should be inside the block of if (text[i] === "h").
  2. The if-else condition should check hits.length === 0 and it should be outside the both the loops.

If that does not make sense, I strongly recommend you redo the exercises of "Search Text for your Name" as well as the previous unit, this time in more detail and with care.