Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expected an identifier and instead saw ')'

I receive this error,

 Expected an identifier and instead saw ')'.

in this lines of code. Any how to fix it?

   for (; index < nPageFullItemCnt; index++) {
        strIndex = "0" + index;
        keyIndex = "popup_item_" + strIndex.substr(strIndex.length - 2, 2);
        keyItem = document.getElementById(keyIndex);

        setPopupKeyText(keyIndex, " ");

        keyItem.className = "popupLangItemNone";
        keyItem.langId = "";
    }
like image 802
GibboK Avatar asked Oct 06 '22 14:10

GibboK


2 Answers

You're not passing in the first parameter to the for() loop:

for (index = 0; index < nPageFullItemCnt; index++) 
{
    /* .. */
}
like image 72
BenM Avatar answered Oct 08 '22 02:10

BenM


This bit:

for (; index

Is causing that error. The code should validate if you do this:

for (0; index

(As I assume you're not passing the first parameter, on purpose)

However, I'd suggest using a while loop, instead of a for, if you're not going to make use of the [initialization]; [condition]; [final-expression] properties in a for loop.

while(index < nPageFullItemCnt){
    // Do stuff;
    index++;
}

Technically, the 3 parameters are all optional, but some code validators can throw a error if they're missing.

like image 27
Cerbrus Avatar answered Oct 08 '22 02:10

Cerbrus