7/7 Victory - program still doesn't work despite completion



Hi all, course keeps completing but the actual program isn't working :frowning: Any suggestions?

/*jshint multistr:true */
var text = "This program will search through a block of text searching for the word Mark, and when when it finds Mark it will push it into a data array that logs all the frequencies of the word Mark.";
var myName = "Mark";
var hits = [];

for (var i = 0; i <= text.length; i++) {
    if (text[i] === 'M') {
        for( var x = i; x < i + myName.length; x++) {
 if(hits.length = 0) {
     console.log("Your name wasn't found!") 
 } else {


this line:

 if(hits.length = 0)

you set the length of hits to zero instead of comparing the length of hits with zero


I am having the same issue. What should the line be changed to? :slight_smile:


at this point in the course i assume you know how to compare operator? Two or three equal signs, if you have more questions please create your own topic


You should push text[x] into your hits array, not text[i]. text[i] continues to equal the same character as you iterate through your "for(var x..." loop, in this case it will always equal "M".