F
26

TIL why my simple calculator code wouldn't run

I was following a tutorial to build a basic calculator in JavaScript. My numbers kept coming out wrong, and I couldn't figure out why. After retyping the function, I realized I had mixed up the order of operations. Fixing that made it work perfectly. It hit me that logic order is just as important as getting the syntax right.
4 comments

Log in to join the discussion

Log In
4 Comments
wyatt135
wyatt1353mo agoTop Commenter
Wait, hold on a second. I have to totally disagree here. Getting the syntax right is way more important than the order of operations for a beginner. If your syntax is broken, the code just won't run at all, you get an error immediately and that's that. A logic error lets you run the program, which is actually a better learning tool because you have to debug a working, but wrong, application. Messing up the logic and then fixing it teaches you more about how the code actually flows. Focusing too much on perfect logic from the start can make you scared to even try writing anything.
8
cora331
cora3313mo ago
Remember teaching my niece to lay tile, wyatt135. She kept freaking out about perfect spacing until I told her to just slap a few down wrong and see why it looks off. Same thing here, I guess.
5
carter.joseph
Wyatt's take that broken code running is better for learning sounds wild to me.
7
zarat38
zarat383mo ago
Think about this... what if fixing a logic error just makes a beginner sure they're right when they're not? That could mess them up worse than a syntax error ever could.
4