Whats wrong with this code?


#1

/*jshint multistr:true */

var text = "ngwenigwe mwenw wopfweo sasa jwopgwpeon sasa nmwengwe ngwieogn";
var myName = "sasa";
var hits = [];


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

if(hits.length === 0) {
    console.log("Broj nije nadjen!!")
}   else    { 
    console.log(hits);
}

#2

Should be

j = i