Your second for loop isn't pushin values into hits array


/*jshint multistr:true */

var text = "This is a string will containing will some will texts";

var myName = "Will";

var hits = [];

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

I couldn't pass this challenge with the above code. Please help correct the codes. Thanks.

Your second 'for' loop isn't pushing values to the hits array

the code relies on the fact, that Will is spelled with first uppercase letter in your text variable.


Thanks for your quick reply.
By changing if(text[i] === "W") from W (uppercase) to w (lowercase), I passed the challenge.


But, now every word that starts with a w gets pushed in your hits array. The idea was you did the exact opposite, change will in your text variable:

var text = "This is a string Will containing Will some Will texts";

and then change your if condition back to:

if(text[i] === "W")


I got it. Thank you very much.