Last active
July 27, 2016 02:20
-
-
Save gregglind/305c79930212f009546629270e6ee681 to your computer and use it in GitHub Desktop.
Loop Party, You are invited.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* some wild-ass loop parties */ | |
var x = 6; | |
var numberArray = [ | |
1, /* 0th item, b/c arrays *index* from 0 */ | |
2, /* 1st item */ | |
3 /* 2nd item */ | |
]; | |
for (ii = 0; /* loop variable starts at 0 */ | |
ii < numberArray.length; /* condition to check at BEGINNING of each loop | |
if TRUE, then we STOP RIGHT NOW */ | |
ii ++ /* what to do BETWEEN loops, after 1st */ | |
) { | |
console.log("start of loop", "ii", ii, 'num', numberArray[ii], "x=", x); | |
x = x + numberArray[ii]; | |
console.log("end of loop X", x) | |
} | |
/* | |
(implict 0th steps: | |
- set ii to 0; | |
- check if 0 < numberArray.length | |
) | |
start of loop ii 0 num 1 x= 6 | |
end of loop X 7 | |
start of loop ii 1 num 2 x= 7 | |
end of loop X 9 | |
start of loop ii 2 num 3 x= 9 | |
end of loop X 12 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment