# Step by Step Explanation of Lessons 6-7

#1

Anyone know where I can find a step-by-step explanation of these two lessons?

#2

++++++++ search text for your name
+++++++++++++++++++++++++++++++++++
paste-in following code....then submit....
you will get an reference-error..no problem !!
analyze the console-output and the code provided to get a better insight...
the \n is new-line
the \t is a tab

``````var text = "alex is the alex";
var myName = "alex";
var hits = [];
console.log("\n\nThe variable myName =" + myName);
console.log(
"Taking the first-letter of myName[0] = " + myName[0] );
console.log(
"Taking the 2nd  -letter of myName[1] = " + myName[1] );
console.log(
"Taking the 3rd  -letter of myName[2] = " + myName[2] );
console.log(
"Taking the 4th  -letter of myName[3] = " + myName[3] );

console.log("\n\nLooping over the whole of text::");
for (var  i = 0; i < text.length; i++) {
console.log(
"i=",i," letter of text at pos",i," is "+"<"+text[i]+">"
);
}

console.log("\n\nFinding the position's"+
"\n\tof the 1st-myName-letter in text");
for (var  i = 0; i < text.length; i++) {
if ( text[i] === myName[0] ) {
console.log(
"i=",i," letter of text at pos",i," is "+"<"+text[i]+">");
}
}

console.log("\n\n-Now find-pos AND "+
"\n-from pos, gather letters"+
"\n-untill pos+myName.length");

console.log('===================');
for (var  i = 0; i < text.length; i++) {
if ( text[i] === myName[0] ) {
console.log(
"i=",i," letter of text at pos",i," is "+"<"+text[i]+">");

for(var j=i; j<(myName.length+i); j++){
console.log(
">j=",j," letter of text at pos",j," is "+"<"+text[j]+">");
hits.push(text[j]);
}

console.log('===================');
}
}
console.log( hits );
error``````