5. Your second "for" loop. I think I may be cheating my way through this lesson?


#1



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


There are no error messages for this one. In fact it says I made it through this exercise alright, but nothing is printing to the console and I get the feeling that the actual JavaScript I'm writing is grammatically correct and all, but not QUITE what codecademy is asking for.


var text = "Persona 5 is coming out soon! James is so \
excited. James can't wait to play it and make his own James story."

var myName = "James"

var hits = []

for (var z = 0; z < text.length; z++) {
    if (text[z] === "J") {
        for (var a = z; a < z + myName.length; a++) {
            hits.push(text[a]);
        }
    }
}


#2

If you need anything to print to the console, you would need to call it in

console.log();


#3

So then I am doing the lesson correctly then? LOL


#4

Your code looks correct. Printing (or logging) the result will be done in the next exercise, but it doesn't hurt to check yourself in this exercise, you can add a console.log() to log something to the console, for example hits:

console.log(hits);

#5

Yup!

Code on! :smile: