```I have a general question and it may be a JavaS...
# suitescript
c
Copy code
I have a general question and it may be a JavaScript specific instance of this happen. I do most of my code work in C# but why would the following code make an infinite loop but declaring the variable outside fixed the issue?for(i = 0; i < transLength; i++)
                {
                    log.debug(transactions.length + ' Total Found Transactions');
                    log.audit('Starting Detail Searches on SO : ' + transactions[i.toString()]);
                    lineItems[i] = getLineItems(transactions[i.toString()]);
                }
a
what was "the variable" you declared outside?
c
i
Once I declared the control variable outside it worked. var i = 0;
a
oh lol yeah you need to declare i
you don't have to do it outside tho, you do it in the for
for(var i =0; ...
just JS syntax
c
Ah, so syntax error. Thanks! I was pulling my hair out!
👍 1
a
some REPLs will auto assign stuff like that for you but NS wont
🙌 1
i think if you ran that in chrome console for example it would just assign i for you
c
Okay, yeah just a weird thing with NS I guess. I appreciate it!