5.Not working!


#1

Number 5 in Search text for your name is not working but I did everything right!
"var text=["Hey", "I", "am", "jeff"," jeff"," jeff!"]
var myName="jeff"
var hits=[1,2,3,4,5]
for(var i=0;i{
console.log(i);
if(text[3]==="jeff"){for(var j=i;j {hits.push(myName);console.log(j)}}
}"


#2

You don't seem to be following the instructions given.
Here's my code:

var text="Hello, my name Jeff"
var myName="Jeff"
var hits=[]
for(var i=0;i<=text.length; i++) {
    if(text[i]==="J") {
        for(var j = i;j<(i + myName.length); j++) {
            hits.push(text[j]);
        }
    }
}

As you can see, completely different.


#3

thanks for your help


#4

Captain, why the "hits.push(text[j])" is inside the loop? Should it be under the "var hits []" ?

Like this:

var text = "Waddup Zub! How are you Zub.";
var myName = "Zub"
var hits = [ ];
hits.push(text[i])


#5

Try this

/*jshint multistr:true */

var text = "Kshitij is a nice boy he loves programming.Kshitij \ always wants to learn something new and different.";

var myName = "Kshitij";
var hits = [];

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

#6

thanks but i am already done