5/7 syntax error: Unexpected end of input


#1

I have absolutely no idea what's wrong. After writing my original code and encountering the same "Unexpected end of input" syntax error (and debugging, but to no avail), I actually copied and pasted the original code in and tried to run it. It worked. When I copied and pasted individual lines and sections, however, completely replacing my original code, I encountered the syntax error. This is what I have now:

text = "Blah blah blah blah blah blah Jacques \
blah blah Jacques blah blah blah blah \
blah blah blah blah blah Jacques";

var myName = "Jacques";
var hits = [];

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

Can anyone help me?


#3

Explanation was great, and I very much appreciate the distinction. Coming from a Python background here, so I was confused about the amount of equal signs. However, the error is still the same, regardless of which one I switched it to


#4

Yes I retracted my statement, as I found that was not at all the error, and I was in turn incorrect about my assumptions. Please disregard my previous statement.


#5

You're just missing a closing bracket at the end of your code.


#6

Oh my god I can't believe it was as simple as that hahaha. Thank you, you just saved me a world of pain


#7

Hi Jacques, can share your code now that it worked? I'm problrmas that part too. Thank you!


#8

This should do it!

text = "Blah blah blah blah blah blah Jacques \
blah blah Jacques blah blah blah blah \
blah blah blah blah blah Jacques";

var myName = "Jacques";
var hits = [];

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

#9

very good, me ajudou bastante!!


#10

Thanks a billion! I literally had no idea what they wanted me to do at this point (other than the obvious for()...