Comes out wrong but I still passed


#1

Instead of the array printing out the letters in my name it just prints out numbers. e,g,
[ 42,
43,
44,
45,
46,
47,
88,
89....
It still let me pass, but I want to get it right. How do i fix this?


/*jshint multistr:true */
var text = "All]Ayy girl, I tried to make you my baby Jaiela \
Ayy girl, instead you make me go crazy \
Just run Jaiela through me \
What have you done to me \
Ayy girl, I tried to make you my baby \
Ayy girl, instead you make me go crazy \
I'm Jaiela losing my cool \
Playing me for a fool \
Ayyyyyy, ayy, ayy girl \
I know your type, I know the life \
I know you living your Jaiela life for the night \
Ayyyyyy, ayy, ayy girl \
I know your type, I know the life \
I know Jaiela you living your life for the night"

var myName = "Jaiela"
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(j);
}
}
}

if(hits.length === 0){
console.log("That's funny, you're name didn't come up");
}else {
console.log(hits)
}


#2

I was too distracted by your amazing story.

At the end of your text string, you need a semicolon after the quote. Also on the line "hits.push(j);" there is something wrong here. Can you figure it out? Look at that entire piece of code and you might be able to figure it out. You're looking for the variable "j" in text!

At the end of your code, you should put a semicolon after console.log(hits) to make it "console.log(hits);". I believe that it in JavaScript it is not necessary to do this, but it is in other languages. It is a good habit to have.

I did not see anything else that I saw wrong other than what I've said. Let me know if you run into any more problems or figured it out.


#3

It worked! Thanks a lot jaaakee! :grin: