Skip to main content
9 votes
Accepted

JavaScript program that calculates the sum and difference of a pair of numbers

Use const instead of let when possible Declaring a variable with let tells JavaScript you ...
Abion47's user avatar
  • 206
6 votes

JavaScript program that calculates the sum and difference of a pair of numbers

Procedural decomposition is a useful tool to manage complexity, and separation of "business logic" from user interaction common. I think the naming of procedures can be improved here: ...
5 votes

JavaScript program that calculates the sum and difference of a pair of numbers

I'm not a JavaScript guy by any means, but I can apply what I know from related languages and let others shoot me down... In setup(), I don't think we need the ...
Toby Speight's user avatar
  • 88.3k
4 votes

JavaScript program that calculates the sum and difference of a pair of numbers

I want to build on @Abion47's answer, because it hits on a lot of key points but misses two crucial items. Your program should not just print successes; it should also print descriptive error ...
Robin's user avatar
  • 141
2 votes

JavaScript program that calculates the sum and difference of a pair of numbers

There are only two hard problems in computing: cache invalidation and getting programmers to pay attention to naming things. Taking the time to figure out good names is the key to being a good ...
TorbenPutkonen's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible