Holy Crap: You’ve Been Coding JavaScript Like A Moron This Whole Time

Look, I get it. You’re a programmer. You’ve got a degree or a startup or a lot of pent-up anger. You know 4 programming languages, and I’m just a guy on the internet running a personal blog in 2016. I’m not going to disrespect that experience, you utter and complete buffoon of a programmer. Let’s just start off with one simple fact: you’ve been writing your code wrong this whole time. How do I know that? I wrote this article that made it to the top of ycombinator and reddit. That qualifies me to tell you off AND feel superior while doing it.

Now that we’re below the fold and I’ve included a stock image, here’s all the JavaScript stuff you’re wrong about, and some best practices:

The Starter Code

Copy and paste this to edit and follow along with the tutorial!

You’ll see that I’m right.

You Goofed Up Semi Colons

It is common practice to write a semicolon at the end of the line of code. In fact, most languages require it. Some do not however. That’s it, right?


Write your semicolons before and after each line. This is the only right way to write code. This is so you can tell where each line of code starts, not just where it ends. The compiler will be so much faster. This is especially true for JavaScript — huge speed boost alert! People also forget the semicolons after braces a lot, but that is super important for writing good JavaScript Parts, just like the book.

Let’s see what that looks like on our code:

Much faster!

Can I Get Your Number?

If you’re NOT storing your integers in strings, I don’t know what’s wrong with you. What good is a number by itself? Nothing. That’s awful and useless. What do we do with numbers? Put them next to words. This creates value for the customer. It’s called semantics, read a book about that sometime. Here’s proof this is the best way:

See? This way, the compiler knows you’re gonna put the People into the sentence right away. This boosts lookup time from the hashtable. Way faster when it runs!

Quit Stringing Me Along

All the other developers use the single or the double quote. Be unique, that is how to stand out among the sheep. I’m a big fan of using only the backtick for strings, and I hope that soon you will be too. When you write code this way, every developer will know it’s yours for sure! How else can they know who to thank?

Frickin Boom.

I Can’t Believe It’s Not Better To Write If Statements Like This

Don’t write “if else if” statements, those are just silly. Break each one into its own if statement so that you can comment out one block at a time to debug that stuff. Come on, it’s common sense:


Youre right David, there are 57.