Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

missing ; after for-loop initializer

Tags:

javascript

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.

like image 810
vissu Avatar asked Apr 19 '11 14:04

vissu


4 Answers

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

like image 84
Brad Christie Avatar answered Nov 02 '22 07:11

Brad Christie


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.

like image 11
Limon Monte Avatar answered Nov 02 '22 06:11

Limon Monte


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

like image 5
Rocket Hazmat Avatar answered Nov 02 '22 08:11

Rocket Hazmat


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.

like image 5
lpd Avatar answered Nov 02 '22 08:11

lpd