😂Sử dụng nhiều toán tử 3, multiple Ternary Operators (ok)

https://stackoverflow.com/questions/7757549/multiple-ternary-operators

var icon = (area == 1) ? icon1 : (area == 2) ? icon2 : icon0;
var icon = getIcon(area);
function getIcon(area) {
  if (area == 1) { 
    return icon1; 
  } else if (area == 2) { 
    return icon2; 
  }
  return icon0;
}

Last updated