CodeCademy Javascript error

1

I'm having trouble creating a for inside of if and get the value of i and inside the second for with var j. I need to compare the var myName with the text and check if they start with the same letter and then make the var hits with the .push () command with variables iej to display.

    
asked by anonymous 18.01.2016 / 21:23

1 answer

2

Hello, I think it would look like this:

var text = "my name is Emerson";
var myName = "Emerson";
var hits = [];
for(i=0; i< text.length; i++){
   if(text[i] === myName[0]){
      for (var j = i; j < myName.length+i; j++) {
        hits.push(myName[j-i]);
      };
   }
}

Hugs, good study.

    
18.01.2016 / 22:02