Answers for "ternary operator."

45

ternary operator

(condition) ? (if true, do this) : (otherwise, do this)
Posted by: Guest on May-14-2020
4

Ternary Operator

condition ? expression-if-true : expression-if-false;

function findGreater(a, b) {
  return a > b ? "a is greater" : "b is greater";
}
Posted by: Guest on December-28-2020
0

ternary operator

// syntax:
condition ? console.log("true") : console.log("false");
// e.g:
let n = 15;
n % 2 === 0 ? console.log("even number") : console.log("odd number");
Posted by: Guest on May-22-2021
0

ternary operator.

print("Equal") if 5==5 else print("Not equal")
5!=5 and 'Equal' or 'Not equal'
Posted by: Guest on July-20-2021

Browse Popular Code Answers by Language