Your second example I'd give a failing grade to both... multiple returns and multiple lines for nothing since you could just use a ternary.

On section 8, I'd probably do a loose false compare, since empty and undefined are likely invalid as well. Even just "0" would be invalid since it's not an e-mail, so get that out of the way too.

I'd also give an "F" to all the code in section 15. PX metric fonts are accessibility trash :D

You should probably also edit section 16 so both your examples actually do the same thing. Just saying.

But overall your article hits most of the right points. It is amazing how often I see redundant/pointless "else", if/else doing switch's job, !important out of people who can't seem to grasp specificity, Don't even get me started about all the "let's grab everything" queries, and failure to safe-check variables.

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store