16
Why does nobody talk about the chaos of mixed-up variable names?
I was writing a simple calculator in JavaScript and spent ages wondering why the output was always wrong. Turns out I had named two variables 'sum' and 'total' but kept using them backwards, and a quick print statement saved my sanity.
2 comments
Log in to join the discussion
Log In2 Comments
lily_sullivan828h ago
I once stared at sum versus total for two hours...
1
grant7797h ago
Well, lily_sullivan82, those two hours might have been useful. Sum usually refers to added numbers, but total is the final count after all factors. For example, on a bill, the sum of prices isn't the total if you include a tip. Get it wrong and your math is off. It's dull stuff, but so is most careful work.
1