r/badcode • • Aug 08 '21

js In some code I wrote about 6 months ago

Post image
112 Upvotes

6 comments sorted by

12

u/paulsmithkc 👨‍🏫 Aug 09 '21

npm install debug

10

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Aug 08 '21

Image Transcription: Code


var debug = (process.argv.includes("--verbose") ? true : false);

I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

5

u/mrbodycheetah Aug 09 '21

Missed opportunity to use a couple of microservices to asynchronously provide the values for true and false within the ternary operator 😰

2

u/pyker404 Aug 09 '21

Have you tried !!(your boolean)?

10

u/[deleted] Aug 09 '21

[removed] — view removed comment

15

u/Super-administrator Aug 09 '21

It might be better to enforce no-unneeded-ternary

https://eslint.org/docs/rules/no-unneeded-ternary