I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
The "before" code made me raise my eyebrows, because I can't imagine anyone creating anything like that by hand. It's the sort of thing that would come out of a code minifier, not out of a human brain.
Then I looked at the "after" code and I think it's worse.
This is a great example of where splitting it up into nicer variable names and keeping each if separate would be better:
letbestCarnivalRide=null;if(mySistersHeight>172){bestCarnivalRide='rollercoaster';if(mySistersFears.indexOf('spiders')>-1){bestCarnivalRide='house-of-horrors';}// etc.
The code provided was just an example and not real code in production.
The real problem I had was with a nested ternary written in a string and then passed to eval. It had a real long nested conditions and babel plugin helped me refactored that code.
I agree with you, no code like that should be in a production application.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The "before" code made me raise my eyebrows, because I can't imagine anyone creating anything like that by hand. It's the sort of thing that would come out of a code minifier, not out of a human brain.
Then I looked at the "after" code and I think it's worse.
This is a great example of where splitting it up into nicer variable names and keeping each
if
separate would be better:The code provided was just an example and not real code in production.
The real problem I had was with a nested ternary written in a string and then passed to
eval
. It had a real long nested conditions and babel plugin helped me refactored that code.I agree with you, no code like that should be in a production application.