-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion on adding an explanation about the for loop in page 2 #41
Comments
Thanks for your suggestion! The while loop just definitely do the trick and the syntax is easier so we decided to prefer it compared to the for loop. But it's interesting to know that the for loop worked better for you. Actually, although the while loop loop looks easier a lot of people don't think about the incrementing of the counter. Maybe that's more obvious with the for loop? Let's keep it open for discussion or better: test it out at the next workshop! |
I got this today at the meet-up. The learner finds using for loop easily. The while loop seems hard to get around. |
Hello there, |
One solution would be function drawing() {
color("red");
var row = 0;
while (row < 20) {
var column = 0;
while (column < 20) {
circle(column * 10, row * 10, 4);
column = column + 1;
}
row = row + 1;
}
} or slightly different but doing exactly the same: function drawing() {
color("red");
var row = 0;
var column = 0;
while (row < 20) {
while (column < 20) {
circle(column * 10, row * 10, 4);
column = column + 1;
}
column = 0;
row = row + 1;
}
} |
The second solution is not usually thought about. But shows how to manipulate the column counter. As the two variables are declared and initialized outside the loop. I vote for second solution. |
Suggestion about explaining the
for
loop in the loop. As, the while loop does not yield in a 20x20 grid in my case.Only using the
for
loop worked out.The text was updated successfully, but these errors were encountered: