Your Second "for" Loop 6/7 error


#1

/*jshint multistr:true */

var text = "Hello, how are you doing today? Today we are going to discuss very important \ matters concerning Joey. Joey is a very good student.................."

var myName = "Joey"
var hits = []

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

It says to make sure that I'm pushing letters to the hits array. Can anyone help me please? It would be greatly appreciated. Also if you could tell me what I did wrong!


#2

It should be:

hits.push(text[j]);

As you want to push the letters, not the number it was found.

P.S. Nice Picture :slightly_smiling:


#3

Ah, thank you! I completely overlooked that. It works now!

And thanks :grinning: Nintendo fan?


#4

I'm a fan of many things, always loved Kirby! :slightly_smiling:


#5

Go Kirby! That's probably one of my favorite series (well, not really true. But I do like Kirby when he's a playable character is Smash Bros. and et cetera.


#6

The Smash Bros. Series is by far my favorite Nintendo game. Not necessarily using Kirby though.


#7

Yeah, same here xD I used to REALLY love Kirby in it. I don't use him that much anymore though, actually, because he's not good in smash 4. I mostly use toon link and luigi now because they're really good combo-fighters