Home / Javascript Tips Generated By ChatGPT / Using the Ternary Operator for Conditional Logic in Javascript The ternary operator provides a shorthand way of writing an if-else statement. Source Code let isAdult = age >= 18 ? 'Yes' : 'No';