I am stuck at this exercise and not sure what mistake I am making



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.

*jshint multistr:true */

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


Seems like you're closing your first loop a little too early.


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