Help with the second 'for' loop!


My code only pushes out the first letter of my name even though codeacademy says I got it right.

/*jshint multistr:true */
var text = "Hey guys it's jasper, how are you doing today. We are \
going to talk today about a question people ask me, jasper...";

var myName = "jasper";

var hits = ['j'];

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


Hey there.

Two things. Firstly, your hits array should be empty to start off with as we are going to be filling it programmatically in the loops.

And also, check out your first for loop's parentheses and what come after it. You've included a semi-colon indicating to the interpreter that anything after it is irrelevant and is not explicitly part of that for loop's condition. Try removing it and see what happens!


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