[Solved] Javascript ternary operator hidden logic


0 in javascript is a falsy value.

var v = 0;

if(v) {
  console.log("true");
} else {
  console.log("false");
}

number % 2 will return either 0 (which is falsy) or 1 (which is truthy). So if the number is even then number % 2 will return 0 and the condition of the ternary will be false, …

solved Javascript ternary operator hidden logic