Why just give me" [] "


#1

var text = "my name is yaman and i was yaman back in time";
var myName = "yaman";
var hits =[];
for (var i=0;i<text.length;i++){if(text[i] === myName[0]){
for
(var j=i;j<(i+myName.length);j++){

hits.push(text[j])}}}
if (hits.length = 0 ){
console.log("your name wasn't found!");}
else {
console.log(hits);
}


#2

You should use the === comparison operator here. The = sign is an assignment operator.


#3

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