X Tutup
  1. Home
  2. Javascript
  3. Ternary

Ternary operator evaluates first parameter followed by two values. First value is returned when the condition is true otherwise the second value is returned.

#javascript#conditional
// Structure 
// Condition ? True : False

var hour = 14;
var day = (hour <= 12) ? "Morning" : "Afternoon";
console.log(day); // Afternoon
copy
Full Javascript cheatsheet
X Tutup