Is it ok to use conditional operators like a statement like so?
(x == y) ? alert(\"yo!\") : alert(\"meh!\");
Or is it more correct to use it to
It is entirely up to you, you can do it either way. You just have to ask yourself, though, does this style follow company guidelines, and how readable do you want this code to be?
Using if statements is way more readable.
Personally, I only use the ternary operator for simple and quick true/false conditions--where doing so makes sense--or where I need something "inline".