For your second loop 5


#1

I have absolutely no idea what I'm doing. Can someone please help me understand what I'm doing wrong, and possibly what I'm misunderstanding? Been stuck here and am clueless.

<P/*jshint multistr:true */

var text = "Blake blah blah Blake blah blah Blake";
var myName = "Blake";
var hits = [];

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


#2

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

Fixed with this. But, still am not 100% sure what hits.push does, if someone could elaborate?


#3

It basically "pushes" or in other words, places, the letters of your name in to the hits array.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.