Forced iterator variable names

for(let myPlacesIndex = 0; myPlacesIndex < myPlaces.length; myPlacesIndex++) {

One should not be forced to use var-names like “myPlacesIndex” in loops during the exercises. IMO this looks really ugly and in the code editor it get’s hard to find a typo. It should be accepted to use i, j and so on. After the second lesson it should be clear, that we need an index variable here, no need to name it.

Style isn’t a cemented standardized thing. Sometimes an explicitly named value will be more clear than i,j,k etc. Sometimes that clarity isn’t necessary. Sometimes it is totally necessary to reference the value of a variable rather than initiating an iterator in for loops

For loops can take a long time to understand for a beginner. Variable names like i or j can complicate that even further.

1 Like

Agree, it could be hard for some and naming is a thing for itself. I just wouldn’t force learners to use “exactlyThisName” in order to progress, that’s what I mean.

+1 agree with cssplayer03018’s approach

Would be better to accept undescriptive variable names, just recommending to use explicit variable names to begginers should be enough.

A question I see all the time
“What does i mean?” “What does j mean in this code?” “Where did this k come from”?
Remember the mindset of a total beginner.
Another important programming concept/practice is following instructions clearly and precisely, understanding that misspelling, case, etc are important.

If you start just accepting any input for iterators in these exercises, you open yourself up to a lot of issues, as well as not doing a new coder justice in their learning.

Not affiliated with the site just my two cents!


I’d disagree here, the example I posted above is already from the second time writing a for loop. Having to use a variable is either clear for some people already or is mentioned in the lesson texts. So one has already seen a for loop before.
Using any name will not create new issues IMO. It should be made clear, how for-loops work and how the syntax looks like.

I think, that failing the step just because you didn’t use exactly the naming provided is not a good way to teach people how to code, this leads to just copy/paste instructions, rather applying it. But yeah it’s not a big deal/issue

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.