Only displaying the []s ... Help!


/*jshint multistr:true */
var text = "This is a string that Josh contains my name \
a few Josh times in order to give us a block \
of Josh text to look through and find it";
var myName = "Josh";
var hits = [];

for (i = 0; i < text.length; i++) {
if (text[i] === "J") {
for (j = i; j < (myName.length + i); j++) {

if (hits.length = 0) {
console.log("Your name wasn't found!");
else {

Results: it just prints the brackets... []. However, it also passes me along with no errors.

I have compared it to the example given in "1. What you'll be building" and the only difference I see is that they do not declare text as a variable (of which I was very confused by.) However, changing that did not affect the results.

If it is not finding my name shouldn't if be triggering my final if statement? Instead it seems to me that it is finding my name but not printing it at the end.


Hi here

if (hits.length = 0)

Change the = with ===


That did it! Thanks!