JavaScript Conditional (Ternary) Operator Explained Simply
The condition is evaluated as a boolean. If the condition is true it returns the first expression, else it returns the second condition.
function progressMessage(completed, total) {
return completed === total ? "All done!" : "Keep learning";
}
console.log(progressMessage(3, 5));
console.log(progressMessage(5, 5)); AI panel
Ask AI to clarify the parts you don’t fully understand, or go more in depth with MDN documentation.