"Log it!" - Submit result isn't logical yet true


#1


Log it!


the code is correct, however for some reason it is only displaying [] when i submit code, even though it says Well done, I'm not really sure it is.
I would love some help here.
thanks


/*jshint multistr:true */
var text="this is some Ziyad text, and here is my Ziyad name.. Ziyad"
var myName="Ziyad"
var hits=[]
for(var i=0;i<=text.length;i++){
    if(text[i]==="Z"){
        for(var j=i;j<i+myName.length;j++){
            hits.push("Ziyad")
            }
    }
}
if(hits.length=0){
    console.log("your name wasn't found")
} else{
    console.log(hits)
}


#2

if(hits.length=0){

hits.length = 0 ? Change here to hits.length == 0

  console.log("your name wasn't found")
} else{
    console.log(hits)
}

#3

thank you! it worked!


#4

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