Don't know what's wrong about this


#1

I don't know what's wrong about this

/*jshint multistr:true */
var text = "Christine Christine Christine";
var myName = "Christine";
var hits = [];
for(i = 0; i < text.length; i++)
{
if(text[i] === 'C')
{
for(var j = i; j < i + myName.length; j++){
}
}
}

newArray = [];
newArray.push('Christine');
newArray[0];

5. Your second "for" loop | It looks like your second 'for' loop isn't pushing values to the hits array
#2

Not sure about this code.

You are supposed to push letters into the hits array using your loops. Try to remove the above code and replace it with some code in your for loop. It should look like this.

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

#3

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