js/js syntax

js template literal에서 삼항연산자(a?b:c, ternary operator) 사용

sunny___ 2022. 6. 2. 14:50
반응형

그냥 이렇게 쓰면 됨, ``내부에 또 ``넣는 건 안되는듯

json.data[0].word
  ? `${json.data[0].word} (${json.data[0].reading})`
  : `${json.data[0].reading}`
반응형