Last Updated: December 26, 2018
·
964
· moak

remembering the order of for()

This may sound silly to some but a couple years back I had difficulty memorizing the order of the 3 parts of a for loop statement, always checking some other piece of code for reference; Like the way I have to check my hands to see the L between my index and thumb in order to know where left is.

Thanks to stackoverflow I know that we all scream for ice-cream

  • Initialize, set the initial value of the variable i = 0
  • Check, that the condition is true i < 10
  • Execute, do something to change conditions for the next step i++

Alternatively there was:

  • First (initialisation)
  • Only while (condition)
  • Rolling on (incrementing or decrementing)

1 Response
Add your response

for (I ; C; E) A;

Every time, "C? A then E".

over 1 year ago ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip