missing ; after for-loop initializer
var nodeWordsString = document.getElementById("nodeWordsTextArea").value.trim();
var nodeWordsStringArray=nodeWordsString.split(" ");
var strLength = nodeWordsStringArray.length;
for(int i = 0; i < nodeWordsStringArray.length; i++)----->******
{
for(int j = 0; j < nodeWordsStringArray.length; j++)
{
if(nodeWordsStringArray(i) == nodeWordsStringArray(j))
{
alert("Node duplication occurred at:"+nodeWordsStringArray(i));
return false;
//break;
}
}
}
**showing error like missing ; after for-loop initializer
in java script console(firebug).
p开发者_高级运维lease help me.
This is javascript, but you're using int
in your loop declaration? Try replacing those with var
instead.
In my case, the error was caused by using let
in the loop. Old browsers like Firefox 38 doesn't support let
.
Replacing let
by var
solved the issue.
Change int i
and int j
to var i
and var j
.
If you are here in 2016, maybe you are trying to use a let
declaration outside strict mode in a browser that does not yet support it. Replace it with var
or add 'use strict;'
to the top of your function.
var strLength = nodeWordsStringArray.length;
for(int i = 0; i < nodeWordsStringArray.length; i++)
You can use for (int i = 0; i < strLength; i++)
it is more efficient. As for your actual error try moving your brackets to the end of your for line. for(..;..;..) {
P.S. as mentioned there is no int
.
精彩评论