We are still cooking the magic in the way!
Problem
Writing verbose if-else statements for simple conditions makes code harder to read and maintain.
Solution
Use the ternary operator (condition ? true : false) for single-line conditional assignments.
Benefit
Reduces code length by up to 70% and improves readability for simple conditions.
Code Example
// Instead of:
if (age >= 18) {
status = 'adult';
} else {
status = 'minor';
}
// Use:
status = age >= 18 ? 'adult' : 'minor';