DEV Community

Discussion on: Javascript Tips for Beginners

Collapse
 
stefandrl profile image
Stefan Drl

I think that ternary operator is good, but! not the nested one (spaghetti code...).
I usually use it when I whant to assign a value to a variable based on a criteria.

Collapse
 
hb profile image
Henry Boisdequin

I agree with you. I just wanted to show that you could do an if, else if, and else with a ternary operator.

Thread Thread
 
_garybell profile image
Gary Bell

Thanks. It looked like you were encouraging people to do it.

I agree that ternary operators have their place, but nesting them in the real world (outside of excel or similar) is just madness