Everything seems to be correct, not sure what's wrong


#1


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


Oops, try again. It looks like your second 'for' loop isn't pushing values to the hits array. Make sure it's working properly and that myName's text appears somewhere in the text variable.


Replace this line with your code. 
/*jshint multistr:true */
var text = ["Hello, my name is Steve. I like the name Steve. Do you?"];
var myName = ["Steve"];
var hits = [];
for (var i = 0; i < text.length; i ++) {
    if (text[i] === 'S') {
        for (var j = i; j < (myName.length + i); j++) {
            hits.push(text[j]);
        }
    }
}


#2

your string variables begins with [ ] but why?
Try without [ ]:

var text = "Hello, my name is Steve. I like the name Steve. Do you?";
var myName = "Steve";

#3

Thanks! I was under the impression they were supposed to be arrays, I've had it like that for all the previous steps. Gotta pay closer attention I guess


#4

Actually string variable is an array of chars. That's why you can use for loop for iteration.


#5

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