Accepted code, but not actually working


#1


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


It accepts it, but shows up with '[]' a bunch on the right.


/*jshint multistr:true */

var text = "Some words/ some words/ some words";
var myName = "Aleksina";
var hits = [];
for(i = 0; i < text.length; i++) {
if (text[i] === 'A') {
    for(j = i; j < myName.length + i; j++) {
       hits.push(text[j]);
    };
    };
console.log(hits);
}

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


#2

Hi this Line

if (hits.length = 0)

You should change the = with ===
___________
Storing value in variable =
Make a comparison between two value == or ===


#3

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