50
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). please help me.

5 Answers 5

123

This is , but you're using int in your loop declaration? Try replacing those with var instead.

Sign up to request clarification or add additional context in comments.

6 Comments

@Raynos: Was going to ask you the same. ;-)
@vissu pepala: Don't worry about it, everyone's here to help without passing judgement. I know I've had many-a-night coding and did a face-palm the next morning to some stupid error I couldn't see the night before. ;-)
Just made the same mistake :-) and found the soln straight away thanks to your question
Same mistake here too. Force of habit is the stronger the deeper the night is.
@Raynos - years have passed and people are making the same mistakes, lol :D [same here]
|
14

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.

1 Comment

I was having the same problem today in FF38 but the really irritating part is that the code works fine in the dev tools console, but not on my page. I tried adding [code]"use strict";[/code] but all that did was create a different error message without a line number.
5

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.

Comments

4

Change int i and int j to var i and var j.

Comments

1
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.