Lesson 6 part 5 i dont know whats wrong


#1

var text = 'Hey guys Im Emmanuel';
var myName = 'Emmanuel';
var hits = [];
for(var i = 0; i > text.length; i++){
if(text[i] === 'E') {
}
for(var j = i; j < (i + myName.length); j++){
console.log(myName);
}
}


#2

What makes you say it's wrong?
There's got to be some kind of problem that you're trying to solve, right? What is that problem? What have you done to try to solve it? What prevents you from doing so?


#3

it says It looks like your second 'for' loop isn't pushing values to the hits array. Make sure it's working properly and that myName's text appears somewhere in the text variable.


#4

Seems like a good start would be to print out that array then and see if that's the case

And when you've identified what's different about that array from what you expected, then you'll have to think about why it would have been different and that'll probably tell you which part of the code wasn't doing its job and you can continue your investigation there


#5

which array is it lol im sorry


#6

Do you mean that you see more than one in your code? Or that you don't see any? Do you know what an array is? What does your code use an array for?


#8

i did that before it didnt work


#9

Your first loop is only firing if i > text.length. Try a less than operator instead;


#10

lol thats crazy it worked :triumph:


#11

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