From 5be661bc899c951c142a6efb6168b10b7b145738 Mon Sep 17 00:00:00 2001
From: tolluset <dlqud19@gmail.com>
Date: Wed, 15 Jan 2025 19:41:25 +0900
Subject: [PATCH] refactor: add BCondition and nested ternary

---
 code/examples/ternary-operator.md    | 15 +++++----------
 en/code/examples/ternary-operator.md | 25 ++++++++++---------------
 2 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/code/examples/ternary-operator.md b/code/examples/ternary-operator.md
index 543bd19..2eb7ed7 100644
--- a/code/examples/ternary-operator.md
+++ b/code/examples/ternary-operator.md
@@ -8,11 +8,11 @@
 
 ## 📝 코드 예시
 
-다음 코드는 `A조건`과 `B조건`에 따라서 `'BOTH'`, `'A'`, 또는 `'NONE'` 중 하나를 `status`에 지정하는 코드예요.
+다음 코드는 `A조건`과 `B조건`에 따라서 `"BOTH"`, `"A"`, `"B"` 또는 `"NONE"` 중 하나를 `status`에 지정하는 코드예요.
 
 ```typescript
 const status =
-  A조건 && B조건 ? "BOTH" : 둘다아닌경우 ? "NONE" : A조건 ? "A" : undefined;
+  (A조건 && B조건) ? "BOTH" : (A조건 || B조건) ? (A조건 ? "A" : "B") : "NONE";
 ```
 
 ## 👃 코드 냄새 맡아보기
@@ -27,14 +27,9 @@ const status =
 
 ```typescript
 const status = (() => {
-  if (A조건 && B조건) {
-    return "BOTH";
-  }
-
-  if (A조건) {
-    return "A조건";
-  }
-
+  if (A조건 && B조건) return "BOTH";
+  if (A조건) return "A";
+  if (B조건) return "B";
   return "NONE";
 })();
 ```
diff --git a/en/code/examples/ternary-operator.md b/en/code/examples/ternary-operator.md
index 23c2e10..4d8be7c 100644
--- a/en/code/examples/ternary-operator.md
+++ b/en/code/examples/ternary-operator.md
@@ -8,17 +8,17 @@ Using complex ternary operators can obscure the structure of the conditions, mak
 
 ## 📝 Code Example
 
-The following code assigns `'BOTH'`, `'A'`, or `'NONE'` to `status` based on `ACondition` and `BCondition`.
+The following code assigns `"BOTH"`, `"A"`, `"B"`, or `"NONE"` to `status` based on `ACondition` and `BCondition`.
 
 ```typescript
 const status =
-  ACondition && BCondition
+  (ACondition && BCondition)
     ? "BOTH"
-    : NotBoth
-    ? "NONE"
-    : ACondition
-    ? "A"
-    : undefined;
+    : (ACondition || BCondition)
+    ? (ACondition
+        ? "A"
+        : "B")
+    : "NONE";
 ```
 
 ## 👃 Smell the Code
@@ -33,14 +33,9 @@ You can rewrite the conditions using `if` statements, as shown below, to make th
 
 ```typescript
 const status = (() => {
-  if (ACondition && BCondition) {
-    return "BOTH";
-  }
-
-  if (ACondition) {
-    return "A";
-  }
-
+  if (ACondition && BCondition) return "BOTH";
+  if (ACondition) return "A";
+  if (BCondition) return "B";
   return "NONE";
 })();
 ```