I passed but the I don't think the code is correct b/c of the output


#1

https://www.codecademy.com/en/courses/javascript-beginner-en-XEDZA/0/5?curriculum_id=506324b3a7dffd00020bf661

I dont get an error message, it says I passed but it logs this as a result, Why is it not logging my entire name [Lindsey]? I am very new to this but have searched the forum for about 3 hours and now I don't know if I should keep going (pass and move on to next lesson) and not understand what I am doing?:

[ 'L',
'i',
'n',
'd',
's',
'e',
'y',
'L',
'i',
'n',
'd',
's',
'e',
'y',
'L',
'i',
'n',
'd',
's',
'e',
'y',
'L',
'i',
'n',
'd',
's',
'e',
'y',
'L',
'i',
'n',
'd',
's',
'e',
'y',
'L',
'i',
'n',
'd',
's',
'e',
'y',
'L',
'i',
'n',
'd',
's',
'e',
'y' ]


/*jshint multistr:true */

var text = "Lindsey is trying to learn JS. Lindsey is \
using code academy to help teach herself. Lindsey keeps \
getting passed on lessons, but results are incorrect.\
Lindsey is confused, and struggling. Lindsey wonders if the.\
hours she has put in to get this far are ever going to amount.\
to some JS knowlegde... Lindsey keeps looking through the Q & A.\
Forum, but finds all the answers overwhelming Lindsey needs.\
Help. Please!";

var myName = "Lindsey";

var hits =[];

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

if (hits.length===0) {
        console.log("your name was not found");
    }
    else {
        console.log(hits); 
    }


#2

Never mind, sorry to waste time. I should have just clicked next lesson and read on. sorry. -Lindsey


#3

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