Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
unwind
· 1y ago · 0 comments
Please don't use if:s to assign boolean literals, just do it:
const trump_tariff = priceIncrease > 1.0
also saves you from not initializing the variable in the default/other case. :)
Comments
[–]
Upvoter33
1y ago
This was just someone showing you what the "Amazon programmer" was doing, and hence a deep cut reference to the likelihood of it being poor quality code :)
[–]
TheSoftwareGuy
1y ago
If you really wanted to look like Amazon codex you would write Java :)
[–]
maxvisser
1y ago
I see I missed an opportunity to make it even funnier.
[–]
throwaway519
1y ago
const
I feel you may underestimate how often they change.
[–]
grokkedit
1y ago
not to mention the mix of snake_case & camelCase
[–]
Someone
1y ago
In the original code,
trump_tariff
is a sticky value. If that’s intended/not intended, the above introduces/fixes a bug.
[–]
ImHereToVote
1y ago
If statements are great because they are highly readable.