SyntaxError: missing ) after condition... help please


#1


I don't know where I went wrong with this and I've changed the code so many times.


/*jshint multistr:true */
var text = "blah blah \ Brandon blah \
blah blah Brandon.";
var myName = "Brandon";
var hits = [];
for (var i = 0; i < text.length; i++); {
    if (text i === "B") {
        for (j === i; j < myName.length + i; j++) {
            hits.push(text[j]);
        }
    }
}
console.log(hits)


#2

There should not be a ";" after ")". Is that the problem?


#3

In your first for loop...

...the semi colon after the closing parentheses should be removed to make it look like this...

for (var i = 0; i < text.length; i++) {


#4

That didn't fix it:/


#5

Try changing
j === i
to
j= i


#6

OK, so here's what happened. There were a few things I was missing like semi colons and []'s. Here is the code that finally passed through. (I had to throw this through dreamweaver to get the answer; along with you guys)
/*jshint multistr:true */
var text = "blah blah \ Brandon blah \ blah blah Brandon.";
var myName = "Brandon";
var hits = [];
for (var i = 0; i < text.length; i++ ) {
if (text [i] === "B") {
for (j =i; j < myName.length + i; j++) {
hits.push(text[j])
}
}
}
console.log(hits)
Don't know why this took so long to handle but I do really appreciate everyone's help!


#7

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