Often when I am making simple if statements, I could make things a lot more concise and readable by using a ternary operator, but don’t know how to, because I want the conditional to do nothing in one of the cases. It throws a syntax error if I just leave an empty space either to the left or right of the colon. Is there a way to make it do nothing and only do whatever I code to the left or right of the colon?
let skyColor = "blue"; skyColor === "black" ? console.log("It is dark outside.") : (do nothing) ;
I have tried using things like
continue(despite knowing it is intended for loops) or
pass, but none seem to work. Couldn’t find anything about that possibility in the MDN, either.