Your second loop!


I'm not sure of what I'm doing wrong. It gives me the error message below. The code looks right to me.

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.

var text = "The bears in the Maria game, and Goldilocks, / have porridge for breakfast. / Maria Tell us about your breakfast.";
var myName = "Maria";
var hits = [];

for (var i = 0; i > text.length; i++) {
    if (text[i] === 'M') {
        for (var j = i; j < (myName.length+i); j++) {


Change > to <, as in,

    i < text.length;


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