Whats wrong with this please


#1



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  = "Hi there how are you";
var myName = "Zico";
var hits = [];

for (var i = 0 ; i < text.length ; i++)
  {
      if
    (text[i] === "Z")
    {
        for (var j = i; j < (myName.length + i); j++)
        {
        hits.push(text[j]);
        }
    }
    
 }     
console.log(hits);.


#2

Just kidding, I lied, but your code looks good except for messy. Let me take a closer look.


#3

i recieved this error message after making this change

Oops, try again. Careful: your second 'for' loop should stop when it reaches its current point in the string + myName.length.


#4

I'm dumb, your code is fine, you just need to make sure that your name is in the text, for example, "Hi there how are you, Zico"
Text needs to be equal to a string with your name in it.


#5

of course! thanks!!!


#6

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