[Solved] What means this javascript “double” ternary condition? [closed]


This is the explanation of your code. Actually, ternary operator is the short form of if else condition.

const dirY = 5;
const dirX = -5;

let y;
let x;

if(dirY != 0){
  if(dirY < 0) {
    y = "N"
  } else {
    y = "S"
  }
} else {
  y = ""
}

if(dirX != 0){
  if(dirX < 0) {
    x = "W"
  } else {
    x = "E"
  }
} else {
  x = ""
}

console.log(y + x)

1

solved What means this javascript “double” ternary condition? [closed]