Not finding my name for Log It!


#1


I've tried with hits.length === 4 as well.


/*jshint multistr:true */

var text = "lorem ipsum asdlkfjlskdj klajsdflksjdl kj \
alskdjfla prop naem name sdkfj ksdjlk name asldkfj lskdj namean";
var myName = "name";
var hits = [];

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

if (hits.length === 3) {
    console.log(hits);
}
else {
    console.log("Your name wasn't found!");
}


#2

@dahaca,
You will have to use

hits.push(text[j])

#3

Still only says "Your name wasn't found!"


#4

@dahaca
You will have to change the last IF condition
from

(hits.length === 3)

into

(hits.length > 0)

#5

I appreciate your help but it's still not working.


#6

@dahaca,
Please display the full code you are using now....


#7

I ended up just looking at the code from step one and fixing accordingly. Still ended up a bit funny in the preview window (all the letters stacked up vertically instead of across the page), but I think I'll just move to the next exercise.


#8

@dahaca,
That is correct, as every character-of-your-name found is 1 Array-Element.....


#9

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