🧠 The Tiny Details That Make You a Better Frontend Dev: Commas, Conditionals & Clarity


🧩 Real-World Context
While working on real-world UI tasks during my internship, I found myself doing something like this:
{title.name} @ {company_name}
// or
{location_state}, {location_country}
// no conditions for missing values
It worked… until one of those values was missing — and the UI ended up showing something weird like:
@ Google
, California
That’s when it clicked: it’s not just about just showing values — But also how you handle if one of them missing. This is where clean, conditional rendering becomes more than just a nice-to-have — it's a must.
🧪 Example 1: Title and Company (@
logic)
❌ Problematic:
<p>{title.name} @ {company_name}</p>
If title.name
is missing, this becomes:
@ Google
Not clean.
✅ Fixed:
{(title?.name || company_name) && (
<p>
{title?.name}
{title?.name && company_name && " @ "}
{!title?.name && company_name && "@ "}
{company_name}
</p>
)}
📌 Output:
Both exist →
Software Engineer @ Google
Only title →
Software Engineer
Only company →
@ Google
🌍 Example 2: State and Country (Comma logic)
❌ Problematic:
<p>{location_state}, {location_country}</p>
If location_state
is missing, you get:
, India
Looks broken.
✅ Fixed:
{(location_state || location_country) && (
<p>
{location_state}
{location_state && location_country && ", "}
{!location_state && location_country}
</p>
)}
📌 Output:
Both exist →
California, USA
Only state →
California
Only country →
USA
🧠 A Quick Reality Check
It’s easy to get caught up in just “getting things to work” — but real frontend maturity is in asking:
“What happens when one of these values is missing?”
And yes — icons too. Showing a location pin icon without a location value? That’s not cool either.
🚫 A Small But Important Reminder
This one’s not code — it’s a mindset:
Don’t become someone who just refactors by copying code or running commands blindly.
Before fixing something or asking for help, ask yourself:
“Why is this error happening?”
“What would break if a value is undefined?”
“What does this refactor really change?”
⚙️ Understand first. Then act. That’s how you grow, not just code.
🎯 Final Thought
Frontend professionalism isn’t always flashy.
Sometimes, it’s just the simple care of not leaving a comma hanging — or an @
with nothing before it.
Subscribe to my newsletter
Read articles from Abhinav Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Abhinav Kumar
Abhinav Kumar
🎓 B.Tech CSE | 👨💻 Learning DSA & C++ | 🚀 Building projects & writing what I learn | 📚 Currently solving LeetCode & exploring Git/GitHub