With this very simple code:
<body>
<script>
var j;
j=0;
do {
document.write("J="+j+" ");
j++;
if (j=4) {
break;
}
}
</script>
</body>
I get an error: Uncaught SyntaxError: Unexpected end of input just at the end of the script. This happens since I'm trying to use break to jump out from the loop.
Of course this is not the code I'm working on, which is way more complicated and needs the break jump. I know in this case a do while loop or for loop would have made it. This is just the smallest code I have showing the error.
Parentheses are balanced, braces are balanced, why does it say it is incomplete?
P.S. I have also tried this very same code as a function, receiving the error Uncaught SyntaxError: Unexpected token } on the brace that closes the function.
if (j=4) {should beif (j==4) {...=is assignment where as==comparison.