For Loops Detected in Variables that contain the word 'for'

I’ve noticed that JavaScript in the interpreter for Codecademy (I’m running Chrome on MacOS Catalina) on courses ‘Learn JavaScript’ and ‘Build Interactive Websites with JavaScript’ detects variables declared that contain the word ‘for’ e.g. ‘fortune’ as containing a for loop.

I couldn’t post this in the bugs section - can anyone advise?


Does the code run as expected, or do you get a syntax error?

One would assume, another genuine error elsewhere notwithstanding, that what you’re seeing is simply the editor getting confused.

An IDE, or a code editor in the case of the learning environment, may have features which make things easier for the programmer - like changing the colour of the text to reflect different aspects of the program, so that keywords (e.g. for) and variables (e.g. button) are stylistically distinct.

Just because the text colour has changed and you’re seeing fortune as part-keyword in blue and part variable in red, doesn’t mean that the scripting engine which will evaluate and run your JavaScript thinks there’s a for loop where there’s a variable.

These things are meant as aids to the programmer, and occasionally they do get it wrong. That’s where it falls to you, as the person writing the program and who is ultimately responsible for what it does or does not do, to look at it and make a judgement as to whether you have made an error there or you’ve simply encountered the coding equivalent of a sat-nav briefly losing GPS and sending you down a wrong side street.