ternary operator syntax js for true value if if code example
Example 1: using ternary operator in javascript
// program to check pass or fail
let marks = prompt('Enter your marks :');
// check the condition
let result = (marks >= 40) ? 'pass' : 'fail';
console.log(`You ${result} the exam.`);
Example 2: js ternary if else
ternary if else example