'for' loop isn't pushing values


Is someone able to point out to me why it doesn't add to the area. Thank you for you help.

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 = "agdk Otto sdfjki Otto dlsafljs Otto alsflj flsjlflaj adsf Otto alfsdjl";
var myName = "Otto";
var hits = [];
for (i = 0; i < text.length; i++)
{ if (text[i] === "O")
for (j = i; j < text[i]+myName.length; j++) {
hits.push (text[j])


Needs a slight change,

    j < i + myName.length;


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