5. Search Text for Your Name exersize


I am struggling with the 5th question in "Search text for Your name"

All it says is
"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."
It looks like everything is right but something is definitely not because I doesn't work :frowning:
Thanks everybody who tries to help

var text =" blah blah blah Nika blah blah blah blah Nika blah blah Nika";
var myName = "Nika";
var hits = [];
for (var i=0; i<text.length; i++);{
if (text[i] ==="N") {
    for (var j=i; j<myName.length+i; j++); {
    hits.push(text [j]);


Erase semi colons after for loops !(from both of your for loops)

syntax of for loop

for (first par; second part;third part) {
  //your code

Your for loops have semicolons like this (below) which is not acceptable in javascript..

for (first part; second part;third part) ; {
//your code


OH! It works. I didn't even look at that part of the syntax ( why is it do important and difficult? -_-)
Thanks a lot


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