Your second "for" loop -I'm stuck


#1

var text = "Hey, how are you \
doing? My name is Emily.";/*jshint multistr:true */
var myName = "Emily";
myName[0];
var hits = [];
for (var i=0; i < text.length; i++) {
if(text[1]=== myName ) {
for (var j = i; j < i+myName.length; i++) {
}
}
}


Replace this line with your code.


#2

HI this line

if(text[1]=== myName )

where you put 1 you should put i and where you put myName you should put myName[0] and here

for (var j = i; i < i+myName.length; i++)

this part

 i < i+myName.length

i will always be less than i +myName.length so uou should change i with j like that

 j < i+myName.length

#3

still its not working :worried:


#4

can you post your new code?


#7

var text = "Hey, how are you \
doing? My name is Emily.";/*jshint multistr:true */
var myName = "Emily";
myName[0];
var hits = [];
for (var i=0; i < text.length; i++) {
if(text[1]=== myName ) {
for (var j = i; j < i+myName.length; i++) {
}
}
}


#8

You didn't what I Said You here

if(text[1]=== myName )

if(text[1]=== myName )
where you put 1 you should put i and where you put myName you should put myName[0] and here


#9

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