F
20

Wrote 500 lines of code before realizing I was using the wrong loop structure the whole time

I spent 2 days debugging JavaScript for a landing page and it turned out forEach was way cleaner than the nested for loops I kept forcing. How did you figure out you were overcomplicating things?
2 comments

Log in to join the discussion

Log In
2 Comments
mitchell.thomas
Nah man, nested loops have their place for complex data structures.
10
the_ben
the_ben6d ago
Tbh I feel you on that one. I was working on a matrix multiplication thing last week and three nested loops were the only way to get it done without making a mess with recursion. Sometimes you just gotta stack them up and keep it simple, you know?
1