-
If condition is true → use valueIfTrue
-
If condition is false → use valueIfFalse
✅ Your amenity example
Your code:
Breakdown:
✔ Condition:
This checks:
“Is the current amenity equal to 'wifi'?”
✔ If condition is TRUE → show:
✔ If condition is FALSE → show:
🎯 Example with your amenitiesList
Looping through each item:
🔹 1. amenity = "wifi"
Check condition:
So ternary returns:
👉 Display: WIFI
🔹 2. amenity = "parking"
Check condition:
So ternary returns:
👉 Display: parking
🔹 3. amenity = "kitchen"
Check condition:
So ternary returns:
👉 Display: kitchen
⭐ Final Summary
The ternary:
Means:
-
If the amenity is wifi → show WIFI
-
If the amenity is not wifi → show its own name
-
You never show two values at the same time for one amenity
Comments
Post a Comment