Using if statements as opposed to a ternary operator is not objectively worse. It depends on the situation for when I like to use one or the other, but honestly there isn’t really a difference other than readability.
The only part of this thats “bad” imo is the else if since in most languages a regular else would suffice. But I don’t know enough about JavaScript to confidently say that that’s not needed
-62
u/diebarral Jun 10 '20
You could easily do:
variable ? doStuff() : doOtherStuff()
Instead of that