The Ternary Operator Fever Dream

The Ternary Operator Fever Dream
javascript-memes, ternary-memes, date-formatting-memes, bad-code-memes, nested-conditionals-memes | ProgrammerHumor.io

This code is what happens when someone discovers nested ternary operators and thinks they've unlocked godmode.

The developer is trying to add the correct suffix to a date (1st, 2nd, 3rd, etc.) with a chain of ternaries that would make even Satan say "that's a bit excessive."

The best part? It completely ignores 4-20, 24-30, and anything else ending with those numbers. Enjoy debugging this masterpiece when it breaks on the 4th of literally any month!

Future maintainers will be adding this developer to their prayer lists tonight.

More Like This