Search Text for Your Name


#1


https://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/1?curriculum_id=506324b3a7dffd00020bf661


Replace this line with your code. 
/*jshint multistr:true */
var text = "dkahvadu Andy djfhif Andy akdjadjao";
var myName = "Andy";
var hits = [];
for (var i=0; i < text.length; i+=1){
if (text[i] === 'A') {
for (var j = i; j < (myName.length + i); j++) {
    hits.push(text[j]);
}
}
}
if (hits.length = 0)
{ console.log("Your name was not found") }
else
{ console.log(hits)}



and the output is just: [] and it says 'congrats, you finished this course'.
I thought it's gonna be ['A', 'n', 'd', 'y'] , like in the example with Eric. What I did wrong?


#2

You used assign operator = but need to use comparsion === .


#3

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