Syntax of conditional operator in JS.
condition ? exprIfTrue : exprIfFalse
Let’s see simple HTML example code for a given condition – If the value is above 30 then pass else fail.
var marks = 80;
var result = (marks >= 80) ? "Pass" : "Failed";
Do comment if you have any doubts and suggestions on this topic.
Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version