"Search text for your name: your second for loop" problems


When I press the submit code button, it freezes without doing anything and I don't know what the problem is with my code.

/*jshint multistr:true */
var text = "Blah blah blah blah Marina blah blah blah Marina blah blah blah blah blah Marina blah blah blah blah blah"

var myName = "Marina"

var hits = [];

for (var loop = 0; loop < (text.length); loop++)
if (text[loop] === "M")
for (var loopy = loop; loopy < (loop + myName.length); loop++)


Should be: loopy++



Those are some interesting variable names you got there...

Check if hits has a length of 0 at the end. This works toward a better user interaction.

if (hits.length==0){
    console.log("Your name wasn't found!");


Instead of just telling them 0, we tell them, your name wasn't found. :slight_smile:


I got, it thanks for the help


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