Log it!


I'm getting the "Way to go!" message, but it is only printing out [ 'B' ] in the results window. Shouldn't it print out [ 'B', 'r', 'i', 'a', 'n' ] ? I've tried over and over and can't get a better result.

var text = "Humpty Dumpty sat on a wall. Humpty Dumpty had a great \ fall. Humpty and Brian were not friends at all.";
var myName = "Brian";
var hits = [];
for (var i = 0; i < text.length; i++) {
    if (text[i] === "B") {
        for (var j = i; j > (myName.length + i); j++);
if (hits.length === 0) {
    console.log("Your name wasn't found!");
} else {


Should be j < ....


I'm having the same problem as OP, but my code already has the <

/*jshint multistr:true */
var text = "Luke has a Luke with the Luke things. He does the things and nobody really understands why he does the things. It looks like Luke knows that text wraps without using the slash so he won't use it. So Luke."
var myName = "Luke";
var hits = [];

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

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


That should be text[n].


Works...and as I was phrasing my question on why, I figured it out. The variable i isn't changing when I increment n to check the next letter as part of my name, so when I push i while in the nested loop, it just re-prints the letter at that position.