Logged array is just filled with the word 'undefined'...?!


#1

Log It!

When I submit the code below, it logs an array whose elements are all just the word 'undefined.' The tutorial tells me I've succeeded, but it certainly doesn't feel like it!

Maybe I'm tired and should come back to this tomorrow; I'm probably missing something obvious but staring at the code isn't helping me see it... Any hints would be appreciated.

var text = "this DDL is a string containing some text DDL about DDL"
var myName = "DDL"
var hits = []

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

    
if (hits.length < 1) 
    {
        console.log("Your name wasn't found!")
    }
else
    {
        console.log(hits)
    }


#2

You need to add in array symbols from var text not from var myName.


#3

Embarrassingly true! Thanks.


#4