Lesson 6 log it


#1


https://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/6?curriculum_id=506324b3a7dffd00020bf661#


There's a problem with my stynax and I can't seem to find it


var text = "Hey what's up Shae \ How are you Shae?";
var myName = "Shae"
var hits = []
for(var i = 0 ;i > text.length ; i++); {
 if (text[5] === "S" );{
 if(text [5] === "h"); 
    { for (j = i; j< i + myName.length; j++);
{
hits.push("Shae");
}
}
 };

if(hits.length === 0); {
    console.log("Your name wasn't found");
}else{
    console.log(hits);
}


#2

after a if statement and a for loop there shouldn't be semi-colons:

if (condition) // no semi-colon {
for (start; stop; step) // no semi-colon {

also, in your first for loop you use >, it should be <, you want i to increase until it is greater then text length (this way it can loop over the entire text)


#3

why do you have this twice:

if (text[5] === "S" )

?
also, it should be text[i] since i is what you use to loop over the string stored in the text variable.

oh and then this line:

hits.push("Shae");

you should push text[j] int your hits array, given the second for loop is what you use to push all instances/letters of your name into the hits array


#4

Thank you so much I was so consummed of trying not to miss any semi-colon's cause i usally do that I overlooked the fact that there is no semi-colon after the if (condition). Thank you so so much