24
My friend's kid asked me to explain what a 'for loop' does while we were waiting for pizza.
I told him it's like giving the same instruction to everyone in a line, one by one, and now I'm wondering if that's actually a good way to teach the concept to someone who's never seen code before.
2 comments
Log in to join the discussion
Log In2 Comments
maxm502d ago
That "line" idea is okay, but it misses the key part about doing something a set number of times. A real for loop is more like telling one person to take three steps, not telling three people to each take one step.
3
parker_bailey2d agoMost Upvoted
But what if you have three people? The line idea works for that case. It just depends on what you're trying to do.
9