Why do we need to input in the last else condition "hits.length"?


#1

I just tried it changing the condiotion with (hits === 0) and it appears the same as using (hits.length === 0) when I push on the submit button.
Is there a difference or both options are ok?
This is the code:

/*jshint multistr:true */
var text = "You are my guest. You can visit my house but you must not touch anything. My name is Mihai and I love sport. blah blah blah Mihai is good with computers.";
var myName = "Mihai";
var hits = [];
for(i = 0; i < text.length; i++) {
    if(text[i] === "M") {
        for(j = i; j < (myName.length + i); j++) {
            hits.push(text[j]);
        }
    }
}
if(hits === 0) {
    console.log("Your name wasn't found!");
}
else {
    console.log(hits);
}

And also, I don't understand what's this /*jshint multistr:true */ for?


#2

@neagumihai54321gmail,

With hits.length you determine, if you have any =elements= in the hits Array.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

For an answer to your second question
read
http://jshint.com/docs/options/