Passed, but don't know why


/*jshint multistr:true */

var text = "i want you and your beautiful soul,\ | i know that you are something special, \ to you i'd be always faithful, \ i want to be what you always needed gabrielle gabrielle gabrielle";

var myName = "gabrielle";

var hits = [];

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

so that is my code above, it keeps reading out 36 but i'm not sure this is what CA was looking for, or how I passed i thought this would tell me my name came up 3 times

... and I was listening to Jessie McCartney while I was doing this.. don't judge me :wink:


You'll need to follow the instructions in step 6 in order to log it.

6. Log It!

Under your existing code (and outside all your loops!), set up an if/else statement. If you don't have any hits, log "Your name wasn't found!" to the console. Otherwise, log the hits array to the console.

**Also, for the sake of clarity while you are learning, change your condition (text[i] === "g" ) to look for a capital 'G'. Then update the capitalization of your name in the text string. Taking this measure isn't absolutely necessary, but it will give you much cleaner results if it's only looking for your capitalized name.

It will result in this:
["G", "a", "b", "r", "i", "e", "l", "l", "e", "G", "a", "b", "r", "i", "e", "l", "l", "e", "G", "a", "b", "r", "i", "e", "l", "l", "e"]

as opposed to this:
["g", " ", "s", "p", "e", "c", "i", "a", "l", "g", "a", "b", "r", "i", "e", "l", "l", "e", "g", "a", "b", "r", "i", "e", "l", "l", "e", "g", "a", "b", "r", "i", "e", "l", "l", "e"]

Happy coding!