2
A simple trick I found for remembering how loops work
Last Tuesday I was stuck on a practice problem about for loops. I kept mixing up where the counter starts and ends. My friend told me to think of it like washing a row of windows, you start at the first one and go until you finish the last. That simple picture made it click for me right away. How do you guys keep track of loop logic when you're starting out?
3 comments
Log in to join the discussion
Log In3 Comments
angelaw783d ago
My buddy used to picture a hamster running laps on a wheel.
5
cameronp473d ago
Man, that's actually genius. I always tried to picture something totally still, like a rock or a frozen lake. It never really worked for me, my brain would just fight it. But a hamster on a wheel? That's active but also kind of pointless and repetitive. It makes sense that it would tire your thoughts out. I'm gonna try that next time my head is too loud to sleep.
5
gray_morgan3d ago
Glad it clicked for you, @cameronp47. The trick is the hamster has to be running backwards on the wheel. Running forwards can still feel like it's getting somewhere, which keeps your brain engaged. Backwards running is just pure, silly effort that goes nowhere. It's the pointless part that really shuts down the noise. Give that a shot instead.
5