Somebody help me on 5/7 PLZ!


#1

This is my exact code and I don't have any idea what I'm doing wrong. Please help me!!!
/*jshint multistr:true */
var text = "fslkajleifj Cierra cflkjfiafl fishaaj geaikajf dgkajliw vliigjs Cierra coihasfihlikokkklkkkkf alfisisehri Cierra soifjelfia, hlushfl Cierra";
var myName = "Cierra";
var hits = [];
for(var i = 0; i < text.length; i++){
if(text[i] === 'C'){
for(var j = i; i < myName.length + i; j++){
hits.push[text j]
}
}
}


#2

Look at your second "for" loop. What is "i < myName.length + i; j++"? In place of the "i", you must put the "j" to make it function.

Hope it helped!:smiley:


#3

You have 2 problems
-1 the condition in your FOR-loop should be
j < myName.length + i;
-2 and the push()-method requires the syntax
hits.push( text[j] );

References:

google search
javascript push array site:developer.mozilla.org
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push

javascript push array site:stackoverflow.com
http://stackoverflow.com/questions/351409/appending-to-array

www.crockford.com
http://javascript.crockford.com/survey.html
http://javascript.crockford.com/code.html


#4

Right. Forgot the other one. :sweat_smile:


#5

Thank you so much. I never would have figured it out on my own. The people here are so helpful... Thanks again. :smile:


#6